Integrate Jmeter With Jenkins and Generate HTML Report

Scripts running in Jmeter could be integrated with Jenkins and can be scheduled to execute at specific time. If Jmeter integrated with Jenkins, then Jmeter interface is not required because Jmeter will execute from command prompt and report will be saved as HTML format.

After following below steps you will learn-

  • How to integrate Jemter with Jenkins.
  • How to generate HTML report once execution is completed.

Before we start integration please make sure you have downloaded Jmeter and Installed Jenkins in your local system.

Integrate Jmeter With Jenkins:

The basic concept of integrating Jmeter with Jenkins is, first create a project in Jenkins and then configure project to execute Jmeter script.

  • Open browser and type localhost:8080 to open Jenkins interface. If you are launching Jenkins first time, it will ask to enter admin password.

JmeterJenkins1

  • Enter administrator password. Administrator password could be found at C:\Program Files (x86)\Jenkins\secrets\initialAdminPassword

JmeterJenkins2

  • Open initialAdminPassword file in notepad and copy the text. Paste the text in Administrator password field and click on Continue button.

JmeterJenkins3

  • If paged lands to Customize Jenkins, then please close with pop up window by clicking on X button shown on right top corner on popup window and Click on Start using Jenkins
  • Click on New Item or Create new jobs You can click on any one of the links to create a job.

JmeterJenkins4

  • Enter any name of your choice in the text box and click on Freestyle project to enable ok button.

 

JmeterJenkins5

  • Click on Apply and Save button. (Configuration we will do later)
  • Go to C:\ drive and create a folder name JmeterProject (You can give any name).
  • Inside folder keep your Jmeter Script. Here I have kept my script name as MyScript.

JmeterJenkins6

  • Keep downloaded Jmeter Installation folder in C:\ drive. Because we need to provide both the files location in Jenkins, that I will show in below steps.

JmeterJenkins7

  • Now again go to Jenkins interface and click on MyFirstJenkinsProject link.

JmeterJenkins8

  • Click on Configure link shown on left side on Jenkins interface.

JmeterJenkins9

  • Look for Build option and Click on Add build step drop down. Select option Execute Windows batch command.

JmeterJenkins10

  • Write below command in command box.
cd C:\apache-jmeter-3.1
cd bin
jmeter -n -t C:\JmeterProject\MyScript.jmx

JmeterJenkins11

  • Click on Apply and then Save. Click on Build Now to run the build and execute the Jmeter script. Once you click on Build Now the build will start executing which you can see at left side on Jenkins interface.

JmeterJenkins12

Here we have successfully updated the build. If build does not execute or shows in red color, please check file path in Build command.

Here it is just showing build executed but actually script executed or not we are not sure, hence we need to generate one html report which will show the test execution report with sampler executed in Jmeter.

Generate html Report Once Build Successful:

  • Go to above step and replace the Build command with below command:
cd C:\apache-jmeter-3.1
cd bin
jmeter -n -t C:\JmeterProject\MyScript.jmx -l C:\JmeterProject\output.csv -e -o C:\JmeterProject\HtmlReport

JmeterJenkins13

  • Click on Apply and Save and Run the build.
  • Go to the folder where you have kept Jmeter script. There will be 2 files created – outfile.csv and HtmlReport.

JmeterJenkins14

Open HtmlReport folder and open index.html file in Firefox or Chrome browser to view the result.

Note: Every time you execute the build please make sure you have deleted output.csv and HtmlReport folder.

JmeterJenkins15

JmeterJenkins16

 

Leave a Reply

Your email address will not be published. Required fields are marked *