Pass command line script execution argument in jmeter and jenkins

Jmeter is really very great and powerful tool. It, not just a performance tool you can use as the functional testing tool. When we work with Jenkins it provides one-click testing. you just create a build and it will run the JMeter script and show you the performance report. Even client can run the JMeter script and see the performance report.

Scenario

When we use JMeter performance test by GUI or CUI (command user interface) we pass the user thread value but the question is how to pass thread parameter value during command user interface. During thread Everytime, we can’t update script .jmx file and it will take extra time to manage.

Solution

We can pass the JMeter thread value argument by command line variable.

Follow the below steps.

Step 1

enter ${__P(USERS)} in Jmeter > Thread > Number of Theads (users) field.

 

Pass command line script execution argument in jmeter and jenkins
Pass command line script execution argument in jmeter and jenkins
Step 2
when you run JMeter script from command line append  -JUSERS= Thread value like  -JUSERS=2. You can do same in Jenkins by passing Thread argument value from Execute window batch command if it is a window if it is Ubuntu use Execute shell command.
See below image
execute-windows-batch-command-jmeter-jenkins
execute-windows-batch-command-jmeter-jenkins

make the build and run.

 

Leave a Reply

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