Jenkins + Jmeter + Ant automation integration build environment (windows platform)

I. Before You Begin

1.JDK:jdk-8u121-windows-x64

2.jmeter tools: apache-jmeter-2.13

3.ANT tools: apache-ant-1.9.7-bin

4.jenkins工具:jenkins-2.32.2

More tools and installation package version Download: pan.baidu.com/s/1pKWPi5d

Second, software installation

1.JDK installation

> Double JDK installation package, select the installation path (C drive system in order to save disc space, not recommended to choose the default path I installed D:. \ Java the \ JDK directory, e.g. Jdk installed in D: \ java \ JDKjdk1.7.0_79 path under);

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

1) → New system variable JAVA_HOME variable.

Fill in the value of the variable jdk installation directory (I is D: \ Progrom Files \ Java \ jdk1.7.0_79);

2) System variables Path variable → Edit → Looking

In the last input value of the variable% JAVA_HOME% \ bin;% JAVA_HOME% \ jre \ bin;

(Note that the original value of the variable Path end there; number, if not, the first input; number enter the code above)

3) System variables → New CLASSPATH variable

Fill in the value of the variable;.% JAVA_HOME% \ lib;% JAVA_HOME% \ lib \ tools.jar (Note that the preceding bit)

System variable configuration is completed

4) verify the configuration successfully run cmd enter java -version (space between java and -version)

If the version information is displayed as shown in FIG successfully install and configure.

 

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

2.jmeter software installation

> Decompression apache-jmeter-2.13.zip to D: \ java \ Jmeter + ant + jenkins \ the apache-jmeter-2.13 directory.

 

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

> Install Jmeter plug-ins. Decompression JMeterPlugins-Extras-1.3.0.zip, JMeterPlugins-Standard-1.3.0.zip, corresponding to the file in the directory ext copied to D: \ java \ Jmeter + ant + jenkins \ apache-jmeter-2.13 \ lib \ ext Under contents;

 

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

> Configure jmeter environment variables:

1) set environment variables, a new system variable input variable name: JMETER_HOME, the input variable value: D: \ java \ Jmeter + ant + jenkins \ apache-jmeter-2.13, and click OK.

2) add the CLASSPATH environment variable% JMETER_HOME% \ lib \ ext \ ApacheJMeter_core.jar;% JMETER_HOME% \ lib \ jorphan.jar;% JMETER_HOME% \ lib \ logkit-1.2.jar;

Add% JMETER_HOME% \ bin in the environment variable Path

3) verify the configuration successfully run cmd input jmeter -v (space between jmeter and -v)

If the version information is displayed as shown in FIG successfully install and configure.

 

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

Third, the installation ANT

> Decompression apache-ant-1.9.7-bin.zip to D: \ java \ Jmeter + ant + jenkins under \ apache-ant-1.9.7-bin directory;

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

> Environment Variables Configuration ANT

1) Create the following environment variables:

ANT_HOME: D: \ Progrom Files \ apache-ant-1.9.7, this is your ANT installation path;

After setting, click "OK" to save.

2) to the last position at the contents of the PATH environment variable:

;% ANT_HOME% \ bin semicolon in front of the note, if PATH is not the last in a semicolon ";" if you want to add, anything can be removed.

Cmd into the command window, type in CMD window ant -version, percussion keys back to the city, it will show ANT version you have installed, if successful show, explain your configuration should be a success.

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

Four, ANT + Jmeter integration

1、将Jmeter所在目录下extras子目录里的ant-jmeter-1.1.1.jar复制到ant所在目录lib子目录之下,ant运行时才能找到

“org.programmerplanet.ant.taskdefs.jmeter.JMeterTask”这个类,之后可以触发Jmeter脚本

2、建了一个目录D:\java\Jmeter+ant+jenkins\JmeterTest\resultLog,目录中分别建立了html和jtl两个文件夹,之后Ant运行之后将jtl中的文件转换成html中

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

3、在D:\java\Jmeter+ant+jenkins\apache-ant-1.9.7-bin文件中建立一个build.xml文件,build.xml内容如下:

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

build.xml代码(pan.baidu.com/s/1nv2xVaL),注意要修改红色框框的内容

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

4、进入Dos窗口,cd到目标路径下(我的是D:\java\Jmeter+ant+jenkins\apache-ant-1.9.7-bin),输入命令ant敲回车,运行结束会有success信息提示

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

五、Jenkins的安装

>接下来安装jenkins,解压下载好的Jenkins并安装,然后就是一路next(可以更改自己的安装路径)。

安装完成之后会自动弹出浏览器,其中地址是http://localhost:8080,因为我之前安装了tomcat(默认端口是8080),因此需要更改jenkins文件配置,找到 jenkins安装目录下\Jenkins\jenkins.xml文件,然后更改端口号,我改成的是6060(httpPort=6060 )

然后重新启动jenkins,打开浏览器,输入http://localhost:6060,打开界面会有一个admin用户登录界面,需要输入密码,给出的英文提示是需要到安装目录文件下找到secrets文件夹,然后再initialAdminPassword文件中复制内容到登录界面的密码框中,登录即可。

打开Jenkins,首次进入会默认让你选择安装插件(此处如果完全不清楚自己需要什么插件,建议全选)。插件安装完成之后,需要设置登录用户,按照自己喜好设置即可。

1、整合内容

 

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."Jenkins主页

2、系统设置->管理插件->可选插件,搜索Performance plugin(Jmeter报告需要),安装此插件

 

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

3、因为需要用到ANT和JDK,所以需要在jenkins中添加插件,选择点击“系统管理”,之后在Global Tool Configuration的界面看到ant和jdk选项,然后将自己本地的ANT和JDK地址填写上

 

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."1

 

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."2

4、配置、测试邮件1

>在系统设置中找到Jenkins Locaction项填入Jenkins URL和系统管理员邮件地址,系统管理员邮件地址一定要配置,否则发不了邮件通知。因为邮件通知都是由系统管理员的邮箱发出来的

 

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

>按照如图所示设置即可,本处设置的是QQ企业邮箱的服务,其他邮箱按照类似设置即可

>>首先在度娘中找到SMTP服务器地址和端口号及设置QQ邮箱的POP3/SMTP服务

 

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

>>在Jenkins中找到邮件通知项,填入SMTP服务器信息及用户名、密码等认证信息

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

测试邮件发送成功之后,Extended E-mail Notification参照上面的设置即可。(注意:必须配置,否则后期项目构建发送邮件将失败)

5、配置、测试邮件2

>进入“系统设置”

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

>设置Jenkins地址和管理员邮箱(不设置管理员邮箱无法发送邮件)

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

>配置系统管理员的邮件属性,点击“高级”

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

>配置系统管理员的邮件属性

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

>配置“邮件通知”,点击“高级”

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

>进入“系统管理”>>>“插件管理”安装邮件通知插件Email Ext Recipients Column PluginEmail Extension Plugin

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

>然后进入到具体的某一job中配置邮件通知

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."图1
"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."图2
"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."图3

>点击“add trigger”

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

(本邮件是程序自动下发的,请勿回复!)

 

项目名称:$PROJECT_NAME

 

构建编号:test_$BUILD_NUMBER

 

svn版本号:${SVN_REVISION}

 

构建状态:$BUILD_STATUS

 

触发原因:${CAUSE}

 

构建日志地址:${BUILD_URL}console

 

构建地址:$BUILD_URL

 

变更集:${JELLY_SCRIPT,template=”html”}

 

>添加附件

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

>将构建日志压缩作为附件也添加到邮件当中发送,需要注意的是,每一次构建都会产生一个报告文档,仓库里会包含有之前构建的所有的报告文档,所以需要打包的是当前这次产生的报告文档,不是之前的构建产生的文档

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

>点击应用“apply”,然后保存

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

>测试能否收到了邮件,点击“立即构建”

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."

6、邮件测试结果(收到邮件)

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."效果图1
"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."效果图2

问题:如果一段时间过后,Jenkins的自动邮件发送失败了,有可能是你修改了qq密码(如果在配置自动发送邮件时用的是QQ邮箱),这时候就需要在QQ邮箱中重新生成“授权码”,将覆盖上去

"I taught you how to set up Jenkins + Jmeter + Ant integrated automation environment."问题点

以上是本人亲测,如有问题或不足之处还望多多指教。

    Original author: keitwo
    original address:  https://www.jianshu.com/p/8b33585ccc1c
    this switched network article reprint this article only to share knowledge, if infringement, please contact the bloggers to delete

Released seven original articles · won praise 6 · views 642

Guess you like

Origin blog.csdn.net/weixin_36273267/article/details/103807287