1、 将 jmeter 脚本放在/var/lib/jenkins/workspace/Jmeter_auto/jmxpath路径下
2、 点击立即构建即可
最终生成的报告会在 /var/lib/jenkins/workspace/Jmeter_auto/jmxpath/时间目录/html/文件夹中,里面包含整个脚本运行的结果
jmeter 安装目录:
/var/lib/apache-jmeter-3.0, ant中原始的build.xml是在jmeter就有的,/var/lib/apache-jmeter-3.0/extras下
ant 安装目录:
/var/lib/apache-ant-1.9.6 ,需要将jmeter中的多个配置都拷贝到ant目录下一份
build.xml, jmeter-results-detail-report_21.xsl,collapse.png,expand.png
原理如下:
1、jenkins 调用ant 的build.xml 进行构建
2、ant的build.xml可调用jmeter的脚本(jmx) 生成jtl内容,
3、将jtl依据jmeter-results-report_21.xsl 转变为html测试报告
附件中 build.xml只能对一个jmx文件进行操作
build2.xml可以对多个jmx文件进行操作
ant-cortrib-1.0b3.jar 是对多个jmx文件进行操作必须的Jar包,使用foreach的包
并必须在build.xml添加如下内容:
对ant-contrib.jar的说明
build.xml 文件
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
Sample build file for use with ant-jmeter.jar
See http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php
To run a test and create the output report:
ant -Dtest=script
To run a test only:
ant -Dtest=script run
To run report on existing test output
ant -Dtest=script report
The "script" parameter is the name of the script without the .jmx suffix.
Additional options:
-Dshow-data=y - include response data in Failure Details
-Dtestpath=xyz - path to test file(s) (default user.dir).
N.B. Ant interprets relative paths against the build file
-Djmeter.home=.. - path to JMeter home directory (defaults to parent of this build file)
-Dreport.title="My Report" - title for html report (default is ‘Load Test Results‘)
Deprecated:
-Dformat=2.0 - use version 2.0 JTL files rather than 2.1
-->
name="jmeter"
classpathref="jmeter.classpath"
classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>
jmeterhome="${jmeter.home}"
testplan ="${testpath}/${test}.jmx"
resultlog="${testpath}/${test}.jtl">
-->
<property name="lib.dir" value="${jmeter.home}/lib"/>
classpathref="xslt.classpath"
force="true"
in="${testpath}/${test}.jtl"
out="${testpath}/${test}.html"
style="/var/lib/apache-ant-1.9.6/jmeter-results-detail-report_21.xsl">
build2.xml
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
Sample build file for use with ant-jmeter.jar
See http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php
To run a test and create the output report:
ant -Dtest=script
To run a test only:
ant -Dtest=script run
To run report on existing test output
ant -Dtest=script report
The "script" parameter is the name of the script without the .jmx suffix.
Additional options:
-Dshow-data=y - include response data in Failure Details
-Dtestpath=xyz - path to test file(s) (default user.dir).
N.B. Ant interprets relative paths against the build file
-Djmeter.home=.. - path to JMeter home directory (defaults to parent of this build file)
-Dreport.title="My Report" - title for html report (default is ‘Load Test Results‘)
Deprecated:
-Dformat=2.0 - use version 2.0 JTL files rather than 2.1
-->
name="jmeter"
classpathref="jmeter.classpath"
classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>
testplan="/var/lib/jenkins/workspace/Jmeter_auto/jmxpath/${jmx.filename}.jmx">
-->
out="${testpath}/temp/${results.html}/${jmx.filename}.html" classpathref="xslt.classpath"
style="${jmeter.home}/extras/jmeter-results-report_21.xsl" >
-->
-->
classpathref="xslt.classpath"
force="true"
in="${testpath}/${test}.jtl"
out="${testpath}/${test}.html"
style="/var/lib/apache-ant-1.9.6/jmeter-results-detail-report_21.xsl">
-->
-->
来源: http://www.bubuko.com/infodetail-1863327.html