Reputation: 8137
I want to use the parameterized-scheduler plugin in Jenkins to run multiple jobs using cron that differ by a parameter. Sadly, the documentation is terrible. Can anyone guide me how to actually get it to work?
Upvotes: 3
Views: 7268
Reputation: 8137
The parameterized-scheduler plugin can be used to define parameters that would be passed by cron into the env. Lets consider an example:
# pass `group1` into the group parameter when this job is run by cron
H 0 * * 0 % group=group1
# pass `group2` into the group parameter when this job is run by cron
H 0 * * 2 % group=group2
in the job itself, you can then print the value of the parameter:
# prints the value of group for this run
echo $group
each time the job is run, the value of 'group' would be different, according to the cron spec above.
you'll need to install the plugin (duh) and then,
create a project with a group
parameter. This is done in the 'General' section - select the 'This project is parameterized' checkbox and add a string parameter with some default value. We'll overwrite the value later in cron.
save your project, and go back to 'configure'.
a new checkbox should appear now in the Build Triggers section: "Build periodically with parameters". Select it and paste the following code:
H 0 * * 0 % group=group1
H 0 * * 2 % group=group2
the above code tells cron to run the task twice, once on Sunday and again on Tuesday, each time using a different value for the 'group' parameter.
Additional notes:
Upvotes: 6