Skip to content

Instantly share code, notes, and snippets.

@Ticlla

Ticlla/build.xml Secret

Created August 4, 2016 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ticlla/fbd60a527105d4eb9e07f98b83ae5705 to your computer and use it in GitHub Desktop.
Save Ticlla/fbd60a527105d4eb9e07f98b83ae5705 to your computer and use it in GitHub Desktop.
build.xml file
<?xml version="1.0"?>
<project name="CPT" basedir="." xmlns:ac="antlib:net.sf.antcontrib">
<description>TestAutomationGuru - Continuous Performance Testing Process</description>
<!-- Read the test properties from build.propertis -->
<property file="build.properties" />
<!-- System & other ant properties -->
<property environment="env" />
<property name="jmeter.home" value="${env.JMETER_HOME}"/>
<property name="test.path" value="${basedir}/test"/>
<property name="test.name" value="test.jmx"/>
<property name="test.result.path" value="${basedir}/result"/>
<property name="test.result.log" value="${basedir}/log"/>
<property name="lib.dir" value="${basedir}/lib"/>
<!-- set classpath with the path containing jars -->
<path id="jmeter.classpath">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<pathconvert pathsep=":" property="jmeter.classpath" refid="jmeter.classpath"></pathconvert>
<!-- call all tasks in this sequence -->
<target name="all"
depends="clean,show-test-properties,run,generate-report,generate-chart"/>
<!-- clean project by removing all the temp files -->
<target name="clean">
<delete dir="${test.result.path}"/>
<delete dir="${test.result.log}"/>
</target>
<!-- show test properties -->
<target name="show-test-properties">
<echo>JMETER_HOME : ${jmeter.home}</echo>
<echo>TEST_PATH : ${test.path}</echo>
<echo>TEST_NAME : ${test.name}</echo>
<echo>THREADGROUP_COUNT : ${threadgroup.count}</echo>
<echo>THREADGROUP_RAMPUP : ${threadgroup.rampup}</echo>
<echo>THREADGROUP_DURATION : ${threadgroup.duration}</echo>
</target>
<!-- jmeter ant task -->
<taskdef
name="jmeter"
classpathref="jmeter.classpath"
classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>
<!-- To run jmeter test -->
<target name="run" depends="clean, show-test-properties">
<!-- create dir -->
<mkdir dir="${test.result.path}"/>
<mkdir dir="${test.result.log}"/>
<jmeter
jmeterhome="${jmeter.home}"
testplan ="${test.path}/${test.name}"
resultlog="${test.result.path}/result.jtl"
jmeterlogfile="${test.result.log}/jmeter.log"
>
<jvmarg value="-Xmx5120m"/> <!-- modify as you wish -->
<!-- Force suitable defaults -->
<property name="jmeter.save.saveservice.output_format" value="xml"/>
<property name="jmeter.save.saveservice.assertion_results" value="all"/>
<property name="jmeter.save.saveservice.thread_counts" value="true"/>
<property name="jmeter.save.saveservice.bytes" value="true"/>
<property name="jmeter.save.saveservice.response_data.on_error" value="true"/>
<!-- values for UDV -->
<property name="threadgroup.count" value="${threadgroup.count}"/>
<property name="threadgroup.rampup" value="${threadgroup.rampup}"/>
<property name="threadgroup.duration" value="${threadgroup.duration}"/>
</jmeter>
</target>
<target name="generate-report">
<tstamp><format property="report.datestamp" pattern="yyyy/MM/dd HH:mm"/></tstamp>
<copy file="${basedir}/src/expand.png" tofile="${test.result.path}/expand.png"/>
<copy file="${basedir}/src/collapse.png" tofile="${test.result.path}/collapse.png"/>
<xslt
classpathref="jmeter.classpath"
force="true"
in="${test.result.path}/result.jtl"
out="${test.result.path}/result.html"
style="${basedir}/src/jmeter-results-detail-report_21.xsl">
<param name="showData" expression="true"/>
<param name="titleReport" expression="CPT--Aggregate-Report"/>
<param name="dateReport" expression="${report.datestamp}"/>
</xslt>
<echo>Report generated at ${report.datestamp}</echo>
</target>
<taskdef uri="antlib:net.sf.antcontrib" resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${lib.dir}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<target name="generate-chart">
<!-- copy this jar to the JMETER_HOME/lib/ext folder -->
<copy file="${lib.dir}/CMDRunner.jar" tofile="${jmeter.home}/lib/ext/CMDRunner.jar"/>
<ac:for param="reportType" list="LatenciesOverTime,TimesVsThreads,ResponseTimesOverTime,ThreadsStateOverTime,TransactionsPerSecond,ResponseTimesPercentiles,ResponseTimesDistribution">
<sequential>
<java jar="${jmeter.home}/lib/ext/CMDRunner.jar" fork="true">
<arg value="--tool"/>
<arg value="Reporter"/>
<arg value="--generate-png"/>
<arg value="${test.result.path}/@{reportType}.png"/>
<arg value="--input-jtl"/>
<arg value="${test.result.path}/result.jtl"/>
<arg value="--plugin-type"/>
<arg value="@{reportType}"/>
<arg value="--aggregate-rows"/>
<arg value="yes"/>
<arg value="--limit-rows"/>
<arg value="20"/>
<arg value="--width"/>
<arg value="800"/>
<arg value="--height"/>
<arg value="600"/>
</java>
</sequential>
</ac:for>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment