1
votes

Question is how to run a jmeter script using jenkins job. Is there any pre-requisites like standard variable names and all.

I have heard that there are different plugins, some can just execute the script as it is while some other can take inputs from gui as well as provides report as chart or graph.

Also some posts says first we need to create ant programs and then need to call them from jenkins.

If possible, please detail the exact procedure and suitable plugin.

3

3 Answers

1
votes

I use the following two methods:

  1. You can run Jmeter in non-GUI mode using command line ("Execute Windows batch command" or "Execute Shell" build step in Jenkins job settings)

jmeter.bat -n -t path_to_your_jmx_script.jmx

Of course, you can do the same by launching Jmeter as a java application or within shell script.

  1. By "Invoke Ant" build step. This method provides you all the benefits of ant. So, just include jmeter in appropriate ant target in your build.xml file. Here is an example (jvmarg and jmeterarg are not required):

    <target name="test" depends="clean">
         <jmeter jmeterhome="${jmeter-home}"resultlogdir="results/jtl">
              <testplans dir="scripts" includes="*.jmx"></testplans>
              <jmeterarg value="-Jbackend=${env.Backend_Address}"/>
              <jvmarg value="-Xmx512m"/>    
              <jvmarg value="-Xdebug"/>
         </jmeter>
    </target>
    

And that's how you can generate nice report:

<target name="report" depends="test">
     <xslt classpathref="xslt.classpath"
           basedir="results/jtl"
           destdir="results/html"
           includes="*.jtl"
           style="${jmeter-home}/extras/jmeter-results-detail-report_21.xsl">
           <param name="showData" expression="${show-data}"/>
    </xslt>    
    <copy file="${jmeter-home}/extras/expand.png" tofile="results/html/expand.png"></copy>
    <copy file="${jmeter-home}/extras/collapse.png" tofile="results/html/collapse.png"></copy>
</target>

Regarding Jenkins plugins - the only one I know (and use) is Performance Plugin that can mark your build as failed/passed based on Jmeter results and generate nice graphs.

1
votes

This site has the detailed information on Jmeter + Ant + Jenkins integration. Other than running the test, you might also be interested in generating reports, charts and mailing the results.

Check here:

http://www.testautomationguru.com/jmeter-continuous-performance-testing-part2/

1
votes

Jenkins doesn't provide any plugins to execute a JMeter test, it is up to you how you will launch it, the choices are in:

So you need to add a build step which will trigger JMeter test execution using one of above approaches. Also you can add Performance Plugin as a post-build action in order to be able to visualise performance trends and set pass and fail criteria.

See Continuous Integration 101: How to Run JMeter With Jenkins article for detailed walkthrough.