鸿 网 互 联 www.68idc.cn

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架

来源:互联网 作者:佚名 时间:2022-07-19 10:51
前置条件:系统已安装jdk 一、下载jmeter包,通过客户端放在安装目录 1、本次安装的版本为unzip apache-jmeter-5.0.zip ??? unzip apache-jmeter-5.0.zip 2、配置环境变量 执行? vim /etc/profile 在后面加

前置条件:系统已安装jdk

一、下载jmeter包,通过客户端放在安装目录

1、本次安装的版本为unzip apache-jmeter-5.0.zip

??? unzip apache-jmeter-5.0.zip

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_Linux

2、配置环境变量

执行? vim /etc/profile

在后面加入:

export?JMETER_HOME=/root/apache-jmeter-5.0?

exportCLASSPATH=$JMETER_HOME/lib/ext/ApacheJMeter_core.jar:$JMETER_HOME/lib/jorphan.jar:$JMETER_HOME/lib/logkit-2.0.jar:$CLASSPATH?

export?PATH=$JMETER_HOME/bin:$PATH:$HOME/bin

3、执行: source /etc/profile? ,让配置生效

4、验证安装

jmeter -v

如果出现:-bash: /root/apache-jmeter-5.0/bin/jmeter: Permission denied

则给jmeter执行文件授权:

执行:chmod 777 /root/apache-jmeter-5.0/bin/jmeter

若看到如下图,则安装成功

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jmeter_02

5、下载报告模板

地址:http://shanhe.me/download.php?file=jmeter.results.shanhe.me.xsl

把报告放到jmeter的extras路径下面:

/root/apache-jmeter-5.0/extras

下载jmeter插件的的jar包

下载地址:https://jmeter-plugins.org/install/Install/

本次的版本为:jmeter-plugins-manager-1.3.jar

把这个jar包放到jmeter的:/root/apache-jmeter-5.0/lib/ext目录下面

二、安装ant

1、下载地址:https://ant.apache.org/bindownload.cgi

本次下载版本为:apache-ant-1.10.6-bin.tar.gz

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jmeter_03

2、上传到服务器与jmeter同一目录,本次的目录为/root

解压文件执行:tar -zxvf apache-ant-1.10.6-bin.tar.gz

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jmeter_04

3、配置环境变量,在/etc/profile后面添加如下信息

ANT_HOME=/root/apache-ant-1.10.6 CLASS_PATH=.:$JRE_HOME/lib PATH=$JRE_HOME/bin:$ANT_HOME/bin export ANT_HOME CLASS_PATH PATH

执行: source /etc/profile

验证安装:

执行:ant -version

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jmeter_05

三、安装tomcat

1、下载安装包

下载地址:https://tomcat.apache.org/download-80.cgi

本次所用的版本为:apache-tomcat-8.5.35.tar.gz

2、上传安装包到服务器

本次放置的目录为/usr

解压执行:? tar -zxvf apache-tomcat-8.5.35.tar.gz

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jenkins_06

3、重命名文件夹

执行:mv apache-tomcat-8.5.35 tomcat-jenkins

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jenkins_07

?????

4、启动tomcat

???? 4.1、执行: cd /data/tomcat-jenkins/bin

???? 4.2、执行?? sh startup.sh

如果见到如下报错:

:Cannot?find?./catalina.sh.The?file?is?absent?or?does?not?have?execute?permission.This?file?is?needed?to?run?this?program

则权限不足:执行chmod 777 /data/tomcat-jenkins/bin/startup.sh

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jenkins_08

??? 4.3、查看进程

执行:ps aux|grep tomcat-jenkins

如下则启动成功,默认端口为8080

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_Linux_09

5、在浏览器访问http://ip地址:8080

见到如下页面说明安装成功

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jmeter_10

四、安装jenkins

下载地址:https://jenkins.io/doc/book/installing/

1、把jenkins的war包放到tomcat的如下目录

?/usr/tomcat-jenkins/webapps

访问http://ip:8080/jenkins

见到如下页面

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jenkins_11

2、根据提示,打开相应的文件获取初始密码

执行:vim /root/.jenkins/secrets/initialAdminPassword

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jenkins_12

3、配置用户

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jmeter_13

4、见到如下页面说明安装成功

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jenkins_14

PS:jenkins配置工作空间

1、vim /usr/tomcat-jenkins/bin/catalina.sh

2、在# OS specific support. ?$var _must_ be set to either true or false.在上面添加一行

export JENKINS_HOME=/usr/local/jenkins

3、编辑profile文件:vi /etc/profile

4、添加:export JENKINS_HOME=/usr/local/jenkins

5、source /etc/profile

6、sh startup.sh

如果jenkins显示似乎已离线

则更改https为http

/usr/local/jenkins/hudson.model.UpdateCenter.xml

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jenkins_15

5、配置ant+jmeter

把extras目录下面的ant-jmeter-1.1.1.jar 拷贝到ant 的lib目录

cp ant-jmeter-1.1.1.jar /root/apache-ant-1.10.6/lib/

6、修改jmeter配置

6.1、将文件中#jmeter.save.saveservice.output_format=csv改为jmeter.save.saveservice.output_format=xml

6.2、修改如下输出信息

jmeter.save.saveservice.data_type=true

jmeter.save.saveservice.label=true

jmeter.save.saveservice.response_code=true

# response_data is not currently supported for CSV output

jmeter.save.saveservice.response_data=true

# Save ResponseData for failed samples

jmeter.save.saveservice.response_data.on_error=false

jmeter.save.saveservice.response_message=true

jmeter.save.saveservice.successful=true

jmeter.save.saveservice.thread_name=true

jmeter.save.saveservice.time=true

jmeter.save.saveservice.subresults=true

jmeter.save.saveservice.assertions=true

jmeter.save.saveservice.latency=true

jmeter.save.saveservice.connect_time=true

jmeter.save.saveservice.samplerData=true

jmeter.save.saveservice.responseHeaders=true

jmeter.save.saveservice.requestHeaders=true

jmeter.save.saveservice.encoding=false

jmeter.save.saveservice.bytes=true

jmeter.save.saveservice.url=true

jmeter.save.saveservice.filename=true

jmeter.save.saveservice.hostname=true

jmeter.save.saveservice.thread_counts=true

jmeter.save.saveservice.sample_count=true

jmeter.save.saveservice.idle_time=true

五、jenkins配置ant

1、全局工具配置

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jenkins_16

2、安装插件:

HTML publisher

3、配置工程

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jenkins_17

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_Linux_18

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jmeter_19

4、修改buid.xml文件

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jmeter_20

???

???????

???

???

???

???

???

???

???

???

???

???

???

???

???????

???????

???

???

???????

???????

???????????

???????????

????????????

???????????

???????

???

???

???

???????

???????

???

???

???

???

???????

???????<xslt

????????????? classpathref="xslt.classpath"

????????????? force="true"

????????????? in="${jmeter.result.jtlName}"

????????????? out="${jmeter.result.htmlName}"

????????????? style="${jmeter.home}/extras/jmeter.results.shanhe.me.xsl">

?????????????

??????

???????

???????

???????????

???????????????

???????????????

???????????

???????

???

5、构建工程

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jenkins_21

6、查看报告

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_Linux_22

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jmeter_23

查看报告如下,感觉确实丑了一些,后面有空再优化一下

?

?

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_Linux_24

若报告样式没有加载出来

则在命令行执行:System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_Linux_25

:

Linux搭建jmeter+ant+jenkins持续集成接口自动化框架_jmeter_26

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

上一篇:K8S系统环境初始化
下一篇:没有了
网友评论
<