Guy Salton is a technical expert on the whole performance testing ecosystem - load testing tools, monitoring tools, CI tools, Networking and Infrastructure. His expertise is helping with POCs and special technical projects for strategic customers. Guy talks at conferences and meetups around the world, writes blog posts and gives webinars.

Learn JMeter in 5 Hours

Start Learning
Slack

Run massively scalable performance tests on web, mobile, and APIs

Dec 07 2016

How to Run a JMeter Test with Jenkins 2.0 Pipelines and GitHub

Jenkins 2.0 was released in April 2016. The main addition on the Jenkins 2.0 version is Jenkins Pipelines, which provide higher resilience and flexibility, as well as parameterization abilities and VCS friendliness. For more information on Jenkins 2.0 Pipelines see here.

 

In this blog post we will go over how to run a JMeter test with Jenkins 2.0 Pipelines and GitHub. This enables you to pull the complete Pipeline script from the Git Repository and lets you manage all changes in your Jenkins project under SCM. No changes are lost, all changes are documented and it’s much easier to manage and maintain your Jenkins project. Also it’s pretty cool.

 

Here are the steps:

 

1. Install Jenkins 2.0.

 

2. Create a Jenkins Pipeline script using Groovy, for running JMeter. Pipelines are defined using Groovy-based DSL so Jenkins and Java APIs can be used to define the job.

 

In this example, I’m running a JMeter script I created called Jenkins_demo1.jmx.

 

node {
  stage 'Run JMeter Test'
  sh '/home/ubuntu/apache-jmeter-3.1/bin/jmeter.sh -n -t /home/ubuntu/Jenkins_demo1.jmx -l test.jtl'
}

 

3. Upload the Groovy script to your GitHub Repository.

 

Upload the Groovy script to your GitHub Repository

 

Upload the Groovy script to your GitHub Repository

 

4. Create a new Jenkins project: New Item -> Pipeline.

 

Create a new Jenkins project: New Item -> Pipeline

 

Create a new Jenkins project: New Item -> Pipeline

 

5. Check the boxes: ‘GitHub project’ and ‘Build when a change is pushed to GitHub’, and set your GitHub Repository project URL.

 

Check the boxes: ‘GitHub project’ and ‘Build when a change is pushed to GitHub’, and set your GitHub Repository project URL.

 

6. Configure your pipeline. Choose the ‘Pipeline script from SCM’ option to pull the pipeline script you created from your GitHub Repository.

 

Configure your pipeline. Choose the ‘Pipeline script for SCM’ option to pull the pipeline script you created from your GitHub Repository.

 

7. Click ‘Save’.

 

That’s it! You can change your Jenkins project using the Pipeline script in your GitHub Repository. All changes will be saved, each change will trigger your build and you can manage your project easily and enjoy all of Jenkins' Continuous Integration capabilities. You don’t need to change anything on Jenkins anymore.

 

For example, I changed my Pipeline script in GitHub to run 250 Virtual Users on my JMeter script (originally it was running 300 Virtual Users):

 

You can change your Jenkins project using the Pipeline script in your GitHub Repository

 

Now I can see the changes in my Jenkins Project.

 

Now I can see the changes in my Jenkins Project.

 

The changes triggered the Jenkins job.

 

The changes triggered the Jenkins test.

 

Congratulations! You can now easily and efficiently run Pipeline scripts from your GitHub Repository on Jenkins 2.0.

Interested in writing for our Blog?Send us a pitch!

Your email is required to complete the test. If you proceed, your test will be aborted.