Integrating JMeter with Jenkins has various advantages. It runs performance tests automatically for every new build. It also generates various performance metrics which can be used to track performance trend over time. And it is relatively simple to integrate JMeter with Jenkins, as we will see in this tutorial.
We will have Jenkins build trigger a Maven file, which in turn will trigger our performance test. At the end of a test, relevant performance metrics can be derived from generated report. Now, let’s start configuring our setup without further ado.
JMeter with Jenkins Setup:
- Start Jenkins.
- Navigate to Manage Jenkins–>Manage Plugins page.
- Select Available tab and search for ‘Performance plugin’.
- Install the plugin and restart Jenkins.
- As we will be using GitHub for this setup, please install GitHub plugin as well.
- Once plugin installation is done, we need to create a new Job in Jenkins. For that, go to Jenkins Dashboard and select New Item option.
- Provide Item Name, select ‘Freestyle project’ and click OK.
- Select Git under ‘Source Code Management’ section.
- Provide ‘Repository URL’. For our GitHub repository, it’s https://github.com/TestingDiaries/maven-jmeter.git.
- Under ‘Branches to build’ section–>Branch Specifier, add branch name for which you want to build.
- Add a Maven build step with ‘verify’ as Goal.
- Now, select ‘Add post-build action’–>’Publish Performance test result report’ option.
- Under ‘Performance report’ drop down box, select ‘JMeter’ option.
- Provide ‘**/*.jtl’ as ‘Report files’. This sets up all the .jtl files as reports.
- Check ‘Archive the artifacts’ check box and provide ‘**/*jtl-report.html’ value as ‘Files to archive’.
- Click Save.
- Record your JMeter script and save it in your Maven project’s src/test/jmeter directory.
- Click Build Now. Once the build is run, you can see various performance reports in Jenkins.
We hope the above tutorial will help you integrate your JMeter tests with Jenkins. Let us know if this setup turns out useful for you.