Jenkins+ant+Jmeter接口测试
一、安装插件
安装Publish HTML reports插件
安装ANT插件,请自行百度搜索
二、Jenkins配置ant
进入【系统管理】->全局工具配置菜单,配置ant,如图:
Jenkins上新增一个任务,构建时选择Invoke Ant
增加构建后步骤
ant构建主要在于build.xml文件,这个网络上是很多的,可根据自己的需要修改
<?xml version="1.0" encoding="UTF-8"?>
<project name="ant-jmeter-test" default="run" basedir=".">
<tstamp>
<format property="time" pattern="_yyyy_MMdd_HHmmss" />
</tstamp>
<property name="jmeter.home" value="/home/test/apache-jmeter-3.3" />
<property name="report.title" value="test"/>
<property name="jmeter.result.jtl.dir" value="/home/test/root/.jenkins/workspace/Jmeter-rwgl/report/jtl"/>
<property name="jmeter.result.html.dir" value="/home/test/root/.jenkins/workspace/Jmeter-rwgl/report/html"/>
<property name="detail" value="_detail" />
<property name="ReportName" value="rwglReport" />
<property name="jmeter.result.jtlName" value="${jmeter.result.jtl.dir}/${ReportName}${time}.jtl" />
<property name="jmeter.result.htmlName" value="${jmeter.result.html.dir}/${ReportName}${time}.html" />
<target name="run">
<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}">
<testplans dir="/home/dyttest" includes="rwgl.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">
<param name="dateReport" expression="${report.datestamp}"/>
</xslt>
<copy todir="${jmeter.result.html.dir}">
<fileset dir="${jmeter.home}/extras">
<include name="collapse.png" />
<include name="expand.png" />
</fileset>
</copy>
</target>
</project>