Reputation: 1124
In a Jenkins job config's Build Triggers section, it is possible to add multiple cron expressions separated on each line in the Schedule textarea e.g:
13 20 * * 0,1,2,3,4,5,6
13 8 * * 0,1,2,3,4,5,6
https://stackoverflow.com/a/44209349/1291886
How would one do this using the job-dsl/pipeline syntax?
Upvotes: 11
Views: 11806
Reputation: 51
As cron
support string parameter, try this with string operation concat with next line (\n
):
cron('41 12 20 10 *' + '\n 41 12 5 11 *' + '\n 41 12 15 11 *')
Upvotes: 1
Reputation: 51
I recommend changing the lines 13 20 * * 0,1,2,3,4,5,6
to 13 20 * * 0-6
, beauty in the details.
Upvotes: 5
Reputation: 1124
Using the job-dsl syntax:
triggers {
cron('13 20 * * 0,1,2,3,4,5,6 \n 13 8 * * 0,1,2,3,4,5,6')
}
From the job-dsl documentation:
To configure a multi-line entry, use a single trigger string with entries separated by \n.
https://jenkinsci.github.io/job-dsl-plugin/#path/freeStyleJob-triggers-cron
Upvotes: 19