I am trying to configure Jenkins Build Parameter "users" ,to be passed as input to JMETER (v5.1) --> No.Of Threads using the function:${__javaScript(Math.round(${XX}))}
While executing test i am getting following error
error : caused by jdk.nashorn.internal.runtime.ParserException::1:12 Expected but found { Math.round(${__jexl())}
Use a variable to store Math.round(${. Test it with println. Then Invoke ${__javaScript(myVariable)}. Nested ${} is a bad idea, groovy interprets them.
as M Navneet Krishna said, your question is a bit succinct for us to provide better answer. But I gave you a method that should help you debug your stuff
Related
I want to pass a custom variable from Job A to Job B. I have tried achieving this using the "Parameterized Trigger" plugin but I didnt work for me.
I am doing it the following way:
On Job A:
execute shell --> export VAR=1
echo $VAR --> is returning 1
Trigger parameterized build on other projects:
PARAM=${VAR}
On JobB:
I have selected this project is parameterized and declared a variable as PARAM. But when I do execute shell --> echo ${PARAM} it returns be ${VAR} instead of 1.
Am I missing anything here ? Any pointers please ? Thanks in advance!!
That's due to the lifetime of VAR is limited within the Execute shell step. If you want variable cross step, even cross from Build to Post Action, you can output the variable to a file in Key = Value pattern, then read it back in Parameterized Trigger
I found a neat way to pass custom variables to downstream job here:
https://sathishpk.wordpress.com/2016/03/01/how-to-passget-parameters-from-shell-command-into-jenkins-other-places/
It worked for me!!
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
You don't have a script variable named users, so you should either log words[0]:
log.info(words[0]);
Or you can log the value of JMeter variable called users:
log.info(vars.get("users"));
Or you can assign words[0] to variable called users:
String users = words[0];
log.info(users);
Also you are saving it as variable, not property, so you can retrieve it elsewhere in script as
${users}
The syntax __P refers to property, so if you want to use it as property, you need to change how you are saving it:
props.put("users", words[1]);
If you do that, ${__P(users,1)} should work
Now, if you want to use this value as number of threads, then you need to do this:
Have Setup thread group with 1 thread, and your script
In the script you must save users as property, otherwise it won't pass between threads
Next thread group then can use it as number of threads
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
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.
I try to test my first Dataflow app by running it in Eclipse.
When I try to pass 4 values for the arguments on "Run Configuration" on "Arguments" tab as following:
projects/poc/subscriptions/poc-TestApp1 poc myDataSet my_logs
I get the error:
Argument 'projects/poc/subscriptions/poc-TestApp1' does not begin
with '--'
adding -- to all arguments produced a different error.
Based on your question, it seems that you have custom argument parsing code in your program (I suppose you're extracting your arguments as args[0], args[1] etc. in your main() function?), but still use PipelineOptionsFactory.fromArgs(args) to configure the options for Dataflow itself.
Dataflow does not support this mixed way of specifying command-line arguments - you need to define your own PipelineOptions to represent your configuration parameters, and specify them prefixed with --.
Please see here for details, in particular here for creating custom options.
I've been using the option Restrict matrix execution to a subset from the Parameterized Trigger Plugin to pass on a combination filter to a rather large Matrix Project where all test execution is made. As the number of tests grow, so does the combination filter (which is dynamically built up) and I seemed to hit the cap. The following job gets this error message:
FATAL: Invalid method Code length 69871 in class file Script1
java.lang.ClassFormatError: Invalid method Code length 69871 in class file Script1
After reading about this problem, it seems to be a JVM constraint after reading the JVM documentation
The value of the code_length item must be less than 65536.
I get the impression that this is not something I can (or even should) tinker with in Jenkins.
My second idea was to go around this problem was to create the combination filter and then pass it as String parameter to the following Matrix Project, then use the Combination Filter option and expand the variable to achieve the same result.
Unfortunately I get this exception when trying to save my Matrix Project with a String parameter as combination filter
javax.servlet.ServletException: groovy.lang.MissingPropertyException: No such property: $COMBINATION_FILTER for class: groovy.lang.Binding
I guess this is because the variable needs to be available in the configuration when saving but I want to inject it when starting the Matrix Project.
I am running out of ideas to solve this problem. Any ideas?
You could try the Matrix Groovy Execution Strategy which is like a super combination filter
If I can quote myself
A plugin to decide the execution order and valid combinations of
matrix projects.
This uses a user defined groovy script to arrange the order which will
then be executed
Disclaimer: I built this plugin
I'm trying make a parameterized build of a new job from my existing job as follows:
I tried both ways:
build('NEXT-DEPLOY-JOB', PARAM_FROM_BUILD:'1.4', DEPLOYMENT_ENVIRONMENT: "QA")
and without paranthesis way:
build 'NEXT-DEPLOY-JOB', PARAM_FROM_BUILD:'1.4', DEPLOYMENT_ENVIRONMENT: "QA"
However in both cases I receive such error:
java.lang.IllegalArgumentException: Expected named arguments but got [{PARAM_FROM_BUILD=1.4, DEPLOYMENT_ENVIRONMENT=QA4}, NEXT-DEPLOY-JOB]
Please tell me, what I am doing wrong here?
The syntax quoted by #Jayan will work, but is deprecated. (And the Workflow syntax has nothing to do with persistence of state.)
Use Snippet Generator to see an example of the right syntax, tailored to the parameter types expected by the particular downstream job you are triggering.
Try something like below( as I learnt from #Jesse Glick, it is deprecated..)
build job: 'NEXT-DEPLOY-JOB', parameters: [new hudson.model.StringParameterValue('PARAM_FROM_BUILD', '1.4'),
hudson.model.StringParameterValue('DEPLOYMENT_ENVIRONMENT', 'QA')
]