| Just can't figure out where better to ask this question: How can I conditionally set the triggers or options parameters? The same logic as suggested for environment variables section can be applied inside options section, e,g. to some values of logRotator() function like this: numToKeepStr: "${params.IS_IT_NIGHTLY ? '4' : '2'}" But how to make it conditional on entire call of the logRotator() function or in triggers section when I would like to call poolSCM() method with different intervals for CI and NIGHTLY builds? I'm looking for something like this:
triggers {
if (params.IS_IT_NIGHTLY==true) {
pollSCM('''# Once a day, between 12:00AM and 1:59AM
H H(0-1) * * * ''')
} else {
pollSCM('''# every five minutes
H/5 * * * * ''')
}
}
If I do that, then I'll get this error:
WorkflowScript: 25: Expected a trigger @ line 25, column 5.
if (params.IS_IT_NIGHTLY==true) {
^
1 error
The whole point of having parameterized Jenkins pipeline jobs is that most of our the Jenkinsfiles for NIGHTLY and CI builds looks almost identical, except the:
- scheduler triggers
- SVN checkout (which differs in checkout strategy, depth of checkout, and other minor details)
- and of course then a true parametrized split weather to perform a limited or fuld build process with relevant tests and deployment locations.
I can't see as it is now implemented how can I achieve this. Thanks, -d |