0

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?

vvv444
  • 2,764
  • 1
  • 14
  • 25
  • I assume you want it to resolve that parameter at build time? If so, the answer below is absolutely what you want. – Arran Sep 24 '15 at 14:55

1 Answers1

4

Groovy interpolates double quoted strings, see String interpolation. You need to use single quotes to avoid the interpolation, e.g. '${PLATFORM}'.

daspilker
  • 8,154
  • 1
  • 35
  • 49