1, ant the file download
https://pan.baidu.com/s/1MrKPKLtkXPoJDkSjYya9RA extraction code i1bv
2, configure the environment variables ant
Window ant set environment variables:
ANT_HOME F:\ant\apache-ant-1.9.8
Path %ANT_HOME%\bin
ClassPath% ANT_HOME% \ lib
Third, verify ant
Whether the installation was successful: ant
View Version: ant -version
if the following occurs, the installation fails:
'Ant' is not an internal or external command, operable program or batch file.
3, jekins configuration
GlobalTool Configuration
After logging jenkins, click on the system management --Global Tool Configuration:
Configuring JDK environment: Click "JDK installation", and configure the JDK directory name
Ant configuration environment: Click "Ant installation", Ant configuration and directory name
4, build.xml document reads as follows
<?xml version="1.0" encoding="UTF-8"?>
<. "" Project name = "jmeter_test" default = "All" basedir =>
<tstamp>
<Property format = "Time" pattern = "yyyyMMddhhmm" />
</ tstamp>
<-! need to change their own local Jmeter directory ->
<Property name = "jmeter.home" value = "D: \ 04-worksapce \ jmeter \ Apache-jmeter-3.2" />
! <- jmeter result report format generated jtl path ->
< name = Property "jmeter.result.jtl.dir" value = "D: \ 04-worksapce \ jmeter_test \ result_log \ JTL" />
! <- JMeter result report generated html format path ->
<Property name = "jmeter.result.html.dir" value = "D: \ 04-worksapce \ jmeter_test \ result_log \ HTML" />
<- prefix generator report ->!
<Property name = "the ReportName" value = "Automated test report "/>
<Property name =" jmeter.result.jtlName "value =" $ {jmeter.result.jtl.dir} / {the ReportName $ $}} {Time .jtl "/>
<property name="jmeter.result.htmlName" value="${jmeter.result.html.dir}/${ReportName}${time}.html" />
<target name="all">
<antcall target="test" />
<antcall target="report" />
</target>
<target name="test">
<taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" />
<jmeter jmeterhome="${jmeter.home}" resultlog="${jmeter.result.jtlName}">
<!-- 声明要运行的脚本。"*.jmx"指包含此目录下的所有jmeter脚本-->
<testplans dir="D:\04-worksapce\jmeter_test\script" includes="ceshi.jmx" />
<property name="jmeter.save.saveservice.output_format" value="xml"/>
</jmeter>
</target>
<path id="xslt.classpath">
<fileset dir="${jmeter.home}/lib" includes="xalan*.jar"/>
<fileset dir="${jmeter.home}/lib" includes="serializer*.jar"/>
</path>
<target name="report">
<tstamp> <format property="report.datestamp" pattern="yyyy/MM/dd HH:mm" /></tstamp>
<xslt
classpathref="xslt.classpath"
force="true"
in="${jmeter.result.jtlName}"
out="${jmeter.result.htmlName}"
style="${jmeter.home}/extras/jmeter-results-detail-report_21.xsl" />
<!-- 因为上面生成报告的时候,不会将相关的图片也一起拷贝至目标目录,所以,需要手动拷贝 -->
<copy todir="${jmeter.result.html.dir}">
<fileset dir="${jmeter.home}/extras">
<include name="collapse.png" />
<include name="expand.png" />
</fileset>
</copy>
</target>
</project>
5, jekins ant build
into the project's own Configuration -> Configuration -> Build -> invoke ant, ant the ant version is set to name the second step set