Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-38375

Build parameters not getting propagated in Pipeline (jenkinsfile).

    Details

    • Similar Issues:

      Description

      When using a Jenkinsfile, if I define a build parameter the parameter is not passed down into the slave/node execution so there's not way to access the values of the build parameter.

      An example Jenkinsfile would be:

      properties([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [[$class: 'StringParameterDefinition', name: 'mode', defaultValue: 'normal']]]])
      node {
        sh "env"
      }
      

      In the example above, I would expect that when I echo 'env' in my slave/node, I should see a environment variable called 'mode' with a value of 'normal' (by default). However, this is not what I see. It seems that the environment variable mode is omitted.

        Attachments

          Issue Links

            Activity

            Hide
            cch0 Jay H added a comment -

            I saw the same behavior. What you can try is to use

            node

            { echo "$mode" }
            Show
            cch0 Jay H added a comment - I saw the same behavior. What you can try is to use node { echo "$mode" }
            Hide
            markhu Mark Hudson added a comment -

            Is this a real issue, or improper usage? I think the real issue is JENKINS-35378

            Show
            markhu Mark Hudson added a comment - Is this a real issue, or improper usage? I think the real issue is JENKINS-35378
            Hide
            abayer Andrew Bayer added a comment -

            So the issue here is that the first run including the properties step adding the parameter doesn't get the parameter in the environment - subsequent runs will have it just fine. There are a number of technical reasons why that's hard to pull off in a Scripted Pipeline, but JENKINS-41929 tracks something similar for Declarative which we might be able to pull off.

            Show
            abayer Andrew Bayer added a comment - So the issue here is that the first run including the properties step adding the parameter doesn't get the parameter in the environment - subsequent runs will have it just fine. There are a number of technical reasons why that's hard to pull off in a Scripted Pipeline, but JENKINS-41929 tracks something similar for Declarative which we might be able to pull off.

              People

              • Assignee:
                Unassigned
                Reporter:
                mdelaney Mike Delaney
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: