Reputation: 3112
I using Jenkins CI with Job DSL and Multijob plugins. I'm attempting to define a parametrized Multijob containing conditional step using DSL, but I fail to figure out the correct syntax. My code:
multiJob("MyJob")
{
parameters {
stringParam("PLATFORM", "Win32")
stringParam("CONFIGURATION", "Release")
}
steps
{
phase("Build") {
job("BuildJob") { sameNode() }
}
conditionalSteps {
condition {
and { stringsMatch("${PLATFORM}", "Win32", false) } { stringsMatch("${CONFIGURATION}", "Release", false) }
}
runner('Fail')
steps {
phase("Prepare installer") {
job("PrepareInstallerJob") { sameNode() }
}
}
}
}
}
Running this I get the following error:
Processing DSL script My.groovy
ERROR: (My.groovy, line 117) No such property: PLATFORM for class: javaposse.jobdsl.dsl.helpers.step.RunConditionContext
Finished: FAILURE
When line 117 is the line containing the "and" condition.
What would be the correct syntax? Why does not it resolve the PLATFORM parameter?
Upvotes: 0
Views: 4108
Reputation: 8194
Groovy interpolates double quoted strings, see String interpolation. You need to use single quotes to avoid the interpolation, e.g. '${PLATFORM}'
.
Upvotes: 4