I have a *declarative* Jenkinsfile.
I want to have a daily build of the develop branch.
I currently have the following trigger:
triggers {
cron(env.BRANCH_NAME == 'develop' ? '@midnight' : '')
}
Now I also want to build the master branch. Not daily, but weekly.
I already know that I can have only one cron expression in triggers.
I know of one solution that works, and that I do not want to use: have a
different cron expression committed to each branch.
I don't want that, because master branches from develop and then gets
merged back into develop. Doing it that way, will cause merge conflicts
that I don't want to deal with.
The other solution is to have a more complex cron expression in the trigger.
In pseudo code:
IF (env.BRANCH_NAME = 'develop')
THEN cron = '@midnight'
ELSE IF (env.BRANCH_NAME = 'master')
THEN cron = '@weekly'
I don't know how to construct the correct syntax for the cron expression.
Is that Groovy? Linux shell? Something else?
If possible, then I would like to avoid "polluting" my declarative pipeline
with script blocks (I don't even know if they are allowed inside triggers).
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/1e0c46fd-6031-41b9-9cac-1fbb622d9fc6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.