Add Build Parameter In Jenkins Build Schedule
Answer :
Basically, with the 'Build periodically' option you can't schedule a Jenkins job with parameters.
However, to schedule a job at different times that needs to use different environments, you have to use the parameterized-scheduler plugin or search for it in (Manage Jenkins -> Manage Plugins -> Parameterized Scheduler).
Examples:
# Parameter1 H/15 * * * * %Parameter1 # Parameter2 H/30 * * * * %Parameter2
Remember you have to have your parameters already setup because the plugin is visible only for jobs with parameters.
The Node and Label parameter plugin can help since it allows you to select individual nodes assuming your different servers qa1 and qa2 are already configured. Hope that clarifies things for you.
With the native Jenkins crontab, it's not possible.
But it should be possible with this plugin: https://github.com/jwmach1/parameterized-scheduler
You have to fork the repo and build this plugin + do a manual installation.
This tutorial explains how to build a custom plugin: https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial
(Setting Up Environment + Building a Plugin)
Maybe not exactly what you want, but it is an interesting hack I found out so I decided to share. You can programmatically set parameters of Jenkins job depending on the environment.
# check if job was trigered by timer if [ $(env | grep -E '^BUILD_CAUSE=TIMERTRIGGER$') ] ; then # your logic here, utilise the power of bash if [ $(date +"%H") -eq 16 ] ; then PARAM=VALUE_1 ; fi if [ $(date +"%H") -eq 17 ] ; then PARAM=VALUE_2 ; fi fi
Comments
Post a Comment