In this article, you will learn how to run JMeter with Jenkins, an essential step to achieving continuous integration (CI).
Let’s dive in
- Introduction
- Creating a JMeter test
- Setting up a Maven project
- Running JMeter from the command line
- Running JMeter from Jenkins
Introduction
So, you have created your first JMeter test and are now wondering how you can make it part of your CI pipeline. Well, you have come to the right place. In this article, you will learn how to run your JMeter tests on Jenkins using Maven. It is assumed that you already know how to use JMeter and can create a Maven project.
Creating a JMeter test
Once you have a JMeter test, you may want to pass parameters from the command line or Jenkins at run time. Let’s assume that you want to specify the number of threads, ramp-up period, and loop count. To do that, use a property function.

Go here to learn more about the __P property function.
Above, we see the properties thread, rampUp, and loopCount added. The “1” after the property name indicates a default value. For instance, if no threads are specified when the test runs, the test will default to running with one thread.
Setting up a Maven project
After setting up the project, you will need to edit its pom.xml file to tell Maven how to run the JMeter tests. You will add the JMeter Maven plugin, the name of the JMeter file (.jmx), and any user properties. When finished, the pom file should look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.automatenow</groupId>
<artifactId>JMeterMavenJenkinsTutorial</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>jmeter-maven-jenkins</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<!-- Add JMeter Maven plugin -->
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>3.5.0</version>
<executions>
<!-- Generate JMeter Configuration -->
<execution>
<id>configuration</id>
<goals>
<goal>configure</goal>
</goals>
</execution>
<!-- Run JMeter tests -->
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
<!-- Fail build if errors are found -->
<execution>
<id>jmeter-check-results</id>
<goals>
<goal>results</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- Specify JMeter file -->
<testFilesIncluded>
<jMeterTestFile>your_jmeter_test.jmx</jMeterTestFile>
</testFilesIncluded>
<!-- Omit time stamp in test results (optional) -->
<testResultsTimestamp>false</testResultsTimestamp>
<!-- Declare user properties -->
<propertiesUser>
<threads>${threads}</threads>
<rampUp>${rampUp}}</rampUp>
<loopCount>${loopCount}</loopCount>
</propertiesUser>
</configuration>
<!-- Needed if you're not running in local environment (optional) -->
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
At the time of writing, the above shows the latest version for each plugin. In the future, you may need to update the versions accordingly.
The next thing you will need to do is to create a folder called jmeter inside src/test in the Maven project and place the .jmx file in that folder. Also, verify that the pom.xml is at the same hierarchy level as the src folder. Please refer to the image below.


Running JMeter from the command line
Here is the command to run the test directly from the command line:
mvn clean -Dthreads=3 -DrampUP=3 -DloopCount=2 verify
As you can see, this command tells Maven to run the test with three threads, a three-second ramp-up period, and a loop count of two. A successful build will look like this:

Running JMeter from Jenkins
Lastly, you will create a Jenkins project to run the JMeter test.
- In Jenkins, click New Item, give your project a name, select Freestyle project and click OK

- Click This project is parameterized in the project’s configuration screen
- Click Add Parameter drop-down menu and select String Parameter
- Enter THREADS in the Name field (you may also enter a Default Value)
- Create two more parameters, RAMP_UP and LOOP_COUNT by following the same steps

- In the Build section, click the Add build step drop-down and select Invoke top-level Maven targets
- Set the Goals field as follows

- Click Save
- Click Build with Parameters; your screen should look as follows

- Enter some values for each of the fields (or leave some of the fields blank)
- Click Build
The build should be successful, and any default values from the JMeter file should take the place of any blank fields.
Congratulations, you can now run your JMeter tests on Jenkins and even take it a step further by adding reporting capabilities using the Jenkins JMeter plugin. Have fun!
Related articles
Follow our blog
Be the first to know when we publish new content.