mac: jenkins + ant + jmeter interface test

   Recent studies using ant Jenkins platform integration testing, online access to a lot of information, will jenkins + ant + jmeter simple to use to record later for easy access. There are many deficiencies, the latter continuously optimized.

  

First, set up the environment

  1, the installation jdk

  2, installation jmeter

  3, install ant

  4, after mounting the above-described software configuration jdk, jmeter, ant environmental variables

  5, locally created bulid.xml file (file contents, see Appendix), create a folder to store the results of html, file folders jtl results

  Local execution jmeter, command-line commands:

      In build.xml file path, execute  ant -buildfile build.xml

      In the non-build.xml file path, execute ant -buildfile% build.xml directory% / build.xml

  

Two, Jenkins configuration

  1, the local build Jenkins

  2, start Jenkins, Jenkins into the browser

  3, the manager jenkins - ant installation and configuration jdk path in this machine> Global Tool Configuration of:

  

 

 

 

  4, create a free-style project, configure the build environment, select with ant, ant version is selected in step 3 to configure the ant and jdk (java)

  

 

 

   

 5, build

  Building block selection step to increase the pull-down item 2, execute shell

 

  ant -buildfile /Users/test/Documents/jmeter/ant/build.xml

 

  

 

 

 

    Then the command input box, enter the command ant, save the configuration

    

 

 

 

 

6, in the Jenkins panel, created to build the project, you can build success

 

 

     

 

 

  Console output can be seen in the success of building:

    

 

 

 

 

 

appendix:

  build.xml file content, modify the path marked red portion of the description according to their file path

  [This section Transfer: https://www.cnblogs.com/xiaoyifenger/p/9103664.html]

 
<?xml version="1.0" encoding="GB2312"?>
<project name="JmeterTest" default="all" basedir=".">
<tstamp>
<format property="time" pattern="yyyyMMddhhmm" />
</tstamp>
< -! Jmeter need to change their own local directory ->
<property name="jmeter.home" value="E:\jmeter\htmlreport\apache-jmeter-3.2\apache-jmeter-3.2" />
<! - jmeter path generated jtl format results reported ->
<property name="jmeter.result.jtl.dir" value= "E:\jmeter\htmlreport\jtl" />
<! - path generated html format reported results jmeter ->
<property name="jmeter.result.html.dir" value= "E:\jmeter\htmlreport\html" />
<-! Prefix report generated ->
<property name="ReportName" value="TestReport" />
<property name="jmeter.result.jtlName" value="${jmeter.result.jtl.dir}/${ReportName}.jtl" />
<property name="jmeter.result.htmlName" value="${jmeter.result.html.dir}/${ReportName}.html" />
<target name="all">
<echo message="start..."/>
<antcall target="clean" />
<antcall target="test" />
<antcall target="report" />
</target>
 
<target name="clean">
<mkdir dir="${env.WORKSPACE}/results/${env.BUILD_ID}" />
</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= "E:\jmeter\htmlreport" includes="*.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">
<xslt 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>

  

  

  

Guess you like

Origin www.cnblogs.com/justdo-it/p/11913089.html