Search code examples
jenkinsparametersjmeterbeanshell

JMeter: more than nine parameters from Jenkins


I am trying to pass more than nine parameters from Jenkins to JMeter4.0. As I was reading, I found out that JMeter does not accept more than 9 parameters. As a workaround, I want to pass all the parameters as a string and split it in JMeter BeanShell.

java -jar -Xms512m -Xmx2048m C:\JMeter4\bin\ApacheJMeter.jar -Jjmeter.save.saveservice.output_format=csv -Jjenkinsparams="%Timetorun%,%Users%" -n -t %JMeterPath%\bin\tests\tests.jmx -l %WORKSPACE%\Results.csv

The tests run on a Windows machine. From this call I have jenkinsparams = "300,2"

I use a BeanShell PreProcessor like this:

String line = "${__P(jenkinsparams)}";
String[] words = line.split(",");
vars.put("timetorun",words[0]);
vars.put("users",words[1]);
log.info(words[1]);
log.info(users);

I tried few log.info to check the values. For words[1] I have the correct value sent from Jenkins: 2. For the users the value displayed is: void. I am trying to use it for Number of Threads as: ${__P(users,1)}.

What am I doing wrong? The values clearly arrive from Jenkins but I have a problem passing it to my variable. Thank you


Solution

  • As long as your command line fits into 8191 characters it should not be a problem to pass as many arguments to JMeter as you want, here is an evidence from Debug Sampler and View Results Tree listener combination

    JMeter 12 parameters

    So keep calm and pass as many parameters as needed via -J command line arguments.


    Be aware that starting from JMeter version 3.1 users are recommended to use JSR223 Test Elements and Groovy language instead of Beanshell so going forward please consider switching to Groovy.