ant + jmeter + jenkins automatic build environment

I. Before You Begin

1.JDKjdk-8u131-windows-x64

2.jmeter工具:apache-jmeter-5.1.1

3.ANT tools: apache-ant-1.10.3

4.jenkins工具:jenkins-2.32.2

More tools and installation package version Download: https://pan.baidu.com/s/1ReeFHN14-YXLpZl93QgMzQ

Extraction code: w65h

Second, software installation

1.JDK installation

> Double- JDK installation package, select the installation path (to save C disk system disk space, select the default path is not recommended ) .

1 ) System Variables New JAVA_HOME variable.

Fill in the value of the variable jdk installation directory (I is C: \ Program Files \ the Java \ jdk1.8.0_131) ;

2 ) system variable to find Path variable editor

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

(Note that the original Path variable value has no end ; number, if not, the first input ; number and then 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 the Java -version ( the Java and -version there is a space between)

If as shown in FIG display version information of the successful installation and configuration instructions.

 

2.jmeter software installation

1) extracting apache-jmeter-5.1.1.zip to E: \ under apache-jmeter-5.1.1 directory.

 

2) Installation Jmeter plugin.

3) Download Plugins Manager

https://jmeter-plugins.org/install/Install/

 

On E: \ apache-jmeter-5.1.1 \ lib \ ext

Directory, and then restart Jmeter, the menu will -Options one more option under Plugins Manager menu, you can open the plug-install, upgrade

4) Configuration jmeter environment variables:

1) set the environment variable, the new system variables in the variable name, enter: JMETER_HOME , variable values, enter: E: \-jmeter the Apache-5.1.1 , and click OK.

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

In an environment variable Path added in % JMETER_HOME% \ bin

3)  verify the configuration successfully run cmd input jmeter

If as shown in FIG display version information is successfully install and configure

 

3 , install ANT

1) extracting apache-ant-1.10.3.jar to E: \ at apache-ant-1.10.3 directory;

2)配置ANT环境变量

新建以下环境变量:

ANT_HOMEE:\apache-ant-1.10.3,此为你的ANT安装路径;

设置完成后,点击"确认"来保存。

在环境变量PATH的最后面添加一下内容:

;%ANT_HOME%\bin 注意前面的分号,如果PATH中最后没有分号";"的话要加上,有的话就可去除。

进入cmd命令窗口,输入ant,点击回车按钮

如果出现如下内容,说明安装成功

4ANT+Jmeter整合

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

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

2)建了一个目录E:\apache-jmeter-5.1.1\TestCase,目录中分别建立了htmljtl两个文件夹,之后Ant运行之后将jtl中的文件转换成html

 



3)在E:\apache-ant-1.10.3文件中建立一个build.xml文件,build.xml内容如下:

 

 

build.xml代码如下

 

 

 

4)进入Dos窗口,cd到目标路径下(我的是E:\apache-jmeter-5.1.1\TestCase),输入命令ant敲回车,运行结束会有success信息提示

 

5Tomcat的安装

1)解压apache-tomcat-9.0.22-windows-x64.zipE:\apache-tomcat-9.0.22目录下;

 

 

2)找到目录bin下的startup.bat,启动Tomcatshutdown.bat:关闭Tomcat

3)Tomcat配置

配置Tomcat之前要保证jdk已经配置完成。

右击,计算机——属性——高级系统设置——打开环境变量的配置窗口,在系统环境变量一栏点击新建。变量名为TOMCAT_HOME,变量值为Tomcat安装目录,此处为:E:\apache-tomcat-9.0.22。点击确定即可。

path中加入%CATALINA_HOME%\bin;(注意加的时候在原变量值后加英文状态下的“;”)

确定后你的Tomcat就配置好了,同样要验证是否配置成功,那就运行Tomcat,点击启动(或Start service)后,打开浏览器,敲入http://localhost:8080,如果出现页面,那么配置成功。

 

6Jenkins的安装

1)下载jenkinswar包,将下载好的jenkins.war放进tomcat/webapps目录下

2)相关配置

登入http://localhost:8080/jenkins,进入Jenkins初始化页面,第一次启动时间可能有点长,耐心等待。进入成功后会看到如下画面,按提示路径打开密码文件,输入密码:

 

解锁后又是一长段时间等待,此后可能出现如下图所示界面:

 

表示无法下载Jenkins插件,可能是因为防火墙导致,而Jenkins插件的安装非常重要,建议翻墙。如无法翻墙,则选择Skip Plugin Installations跳过插件安装。进入以下页面,设置登陆用户:

 

设置成功后即进入Jenkins主界面:

 

创建一个Freestyle project的项目,名称自定义,我创建是名称为Case01

 

对新建的项目进行构建

 

jenjkns工作路径下,找到项目的文件夹

在项目文件夹下新建report文件夹,build.xml文件,jmeter项目放到项目文件夹下

 

build.xml文件内容如下:

 

在report文件夹下新建htmljtl文件夹,如下图(htmljtl用来存放构建之后的报告)

 

系统设置->管理插件->可选插件,对以下插件进行安装

Performance pluginJmeter报告需要

Email Ext Recipients Column Plugin邮件通知插件

Email Extension Plugin邮件通知插件

 

 

 

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

 

配置、测试邮件

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

 

 

 

>>按照如图所示设置即可,本处设置的是QQ邮箱的服务

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

 

 

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

>>Extended E-mail Notification点击“高级”

 

 

>>配置下图内容

 

>>在Jenkins中找到邮件通知项,填入以下信息

 

 

>>测试邮箱

① 勾选通过发送测试邮件测试配置

② 输入收件邮箱

③ 点击Test configuration按钮

④ 下方显示Email was successfully sent”,表示发送成功,收件邮箱可以收到一条邮件

 

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

在构建下做以下配置

1)配置命令(路径为该项目的路径)

2)配件lncoke Ant

① 点击添加构建步骤

② 选择lncoke Ant进行添加

③ Ant Version 选择Default

④ Build File填写build文件的路径

 

在构建后操作下做以下配置,点击保存

 

 

 

然后对该项目进行构建,构建成功之后,接收的邮件可以收到邮件信息

Guess you like

Origin www.cnblogs.com/wendy-0901/p/11368080.html