Search This Blog

Breaking

Friday, 7 May 2021

[Jmeter]-> Running Jmeter JMX files from Jenkin with the help of Maven Project

 Recently I was trying to run the JMeter project with Jenkin and I found some interesting information about it. Let me share what steps I followed. 





1. First I create a java maven project in my local machine.

2. Then create a jmeter directory inside your src/test path.

3. Inside this, put your jmx file.

4. Now go to your pom.xml file. And put the following plugin and dependencies.

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.1.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>


<plugin>
<groupId>de.codecentric</groupId>
<artifactId>jmeter-graph-maven-plugin</artifactId>
<version>0.1.0</version>
<configuration>
<inputFile>${project.build.directory}/jmeter/results/20170319-BlazeDemo Home Page.jtl</inputFile>
<graphs>
<graph>
<pluginType>ResponseTimesOverTime</pluginType>
<width>800</width>
<height>600</height>
<outputFile>${project.build.directory}/jmeter/results/BlazeDemo Request.png</outputFile>
</graph>
</graphs>
</configuration>
</plugin>


</plugins>
5. That's it. Now open the terminal and run the following command:

mvn verify

6. It will run your jmeter result in non -gui mode.

Before that, make sure, you have put following changes in jmeter user.properties file. (It will be inside jmeter bin file and this is needed for reporting purposes.)

jmeter.save.saveservice.output_format=xml

7. Once this local setup will be ready, you can create maven job in jenkin.

8. Inside that JSON, add this command in pre-built steps.

9. In the post-build section, add this path for the report to come in the Performance report plugin:

**\target\jmeter\results\*.jtl

10. Now save the job and click on the build.

No comments:

Post a Comment