Directory
[TOC]
First, jmeter and ant environment construction
JMeter environment Building is relatively simple, upload the JMeter package to Linux, unzip can, but need to configure environment variables, the configuration environment variable code is as follows
export ANT_HOME=/usr/local/ant/apache-ant-1.10.1export JMETER_HOME=/usr/local/jmeter/apache-jmeter-3.3export CLASSPATH=$CLASSPATH:$JMETER_HOME/lib/ext/ApacheJMeter_core.jar:$JMETER_HOME/lib/jorphan.jar:$JMETER_HOME/lib/logkit-2.0.jar:export PATH=$PATH:$HOME/bin:$JMETER_HOME/bin:$ANT_HOME/bin
Second, Jenkins Environment construction
Jenkins Environment Construction Please refer to my another article
# 2.1 Required Plugins for environment construction
- Performance Plugin
- HTML Publisher Plugin
- Ant Plugin
Third, jmeter and ant integration
- Locate the Ant-jmeter-1.1.1.jar under the Extras directory in the JMeter installation directory, and move it to the Lib directory under the ant installation directory
- Locate the Xalan-2.7.2.jar and Serializer-2.7.2.jar files in the Lib directory and move them to the Lib directory under the ant installation directory
- Modify the Bin/jmeter/properities file in the JMeter installation directory, modify the Jmeter.save.saveservice.output_format=xml
Iv. Preparation of Build.xml documents
The Build.xml document is written in the following directions:
<?xmlVersion= "1.0" encoding= "UTF-8"?><projectname="Ant-jmeter-test"default="Run"basedir="."> <!--need to change to their local Jmeter directory-- <propertyname="Jmeter.home"value="/usr/local/jmeter/apache-jmeter-3.3" /> <propertyname="Report.title"value="Environment Building test Project"/> <!--jmeter Generate JTL Format Results report path-- <propertyname="Jmeter.result.jtl.dir"value="/usr/local/jmeter/apache-jmeter-3.3/reports" /> <!--JMeter generates a path to the results report in HTML format -- <propertyname="Jmeter.result.html.dir"value="/usr/local/jmeter/apache-jmeter-3.3/reports" /> <!--generated report prefixes-- <propertyname="ReportName"value="Testreport" /> <propertyname="Jmeter.result.jtlName"value="${JMETER.RESULT.JTL.DIR}/${REPORTNAME}.JTL" /> <propertyname="Jmeter.result.htmlName"value="${jmeter.result.html.dir}/${reportname}.html" /> <targetname="Run"> <antcalltarget="Test" /> <antcalltarget="Report" /> </target> <targetname="Test"> <taskdefname="JMeter"classname="Org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" /> <jmeterjmeterhome="${jmeter.home}"resultlog="${jmeter.result.jtlname}"> <!--declares that the script to run "*.jmx" refers to all JMeter scripts that contain this directory-- <testplansdir="/usr/local/jmeter/apache-jmeter-3.3/demos"includes="TEST_BAIDU.JMX" /> <propertyname="Jmeter.save.saveservice.output_format"value="xml"/> </jmeter> </target> <pathid="Xslt.classpath"> <filesetdir="${jmeter.home}/lib"includes="Xalan*.jar"/> <filesetdir="${jmeter.home}/lib"includes="Serializer*.jar"/> </path> <targetname="Report"> <tstamp> <formatproperty="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"> <paramname="Datereport"expression="${report.datestamp}"/> </xslt> <!--Because when the report is generated, the associated pictures are not copied to the target directory, so you need to manually copy- - <copytodir="${jmeter.result.html.dir}"> <filesetdir="${jmeter.home}/extras"> <includename="Collapse.png" /> <includename="Expand.png" /> </fileset> </copy> </target></project>
V. Building a Jenkins Mission
You can also get the test report file generated on Linux directly from Jenkins via the setup of Jenkins, and get the rough performance data of the script.
In addition, the test results can be sent to project stakeholders via mail, and the way to send messages using Jenkins is also mentioned in another article.
Jenkins01:linux+jenkins+ant+jmeter Integration