Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins: Multiple cron expressions using the job-dsl/pipeline syntax

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?

like image 708
edst Avatar asked Mar 02 '18 01:03

edst


1 Answers

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

like image 124
edst Avatar answered Oct 16 '22 21:10

edst