Build parameter availability in DSL from pipelines

27 views
Skip to first unread message

Arvind Jayaprakash

unread,
Aug 15, 2016, 12:51:51 AM8/15/16
to job-dsl-plugin
(repost of JENKINS-36679)

I am trying to execute a grrovy DSL script as part of a pipeline. The basic structure is as follows

        step([
            $class: 'ExecuteDslScripts',
            scriptLocation: [targets: ['myseed.groovy'].join('\n')],
        ])


The pipeline job contains a string parameter named as gitProject. Trying to access it's value by using"${gitProject}" from within the groovy DSL results in an error that says gitProject is not defined. Trying to wrap the step as follows doesn't help either


    withEnv(["gitProject=$gitProject"]) {
        sh 'set'
        step([
            $class: 'ExecuteDslScripts',
            scriptLocation: [targets: ['myseed.groovy'].join('\n')],
        ])
    }


My guess is that the withEnv approach would not work as job DSLs do not have access to all environment variables; only whitelisted ones and build parameters make it. In short, is to possible for the DSLs to access the build paramaters when run as a pipeline step?

Reply all
Reply to author
Forward
0 new messages