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

Build parameters not getting propagated in Pipeline (jenkinsfile).

      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.

          [JENKINS-38375] Build parameters not getting propagated in Pipeline (jenkinsfile).

          Mike Delaney created issue -

          Jay H added a comment -

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

          node {
          echo "$mode"
          }

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

          Mark Hudson added a comment -

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

          Mark Hudson added a comment - Is this a real issue, or improper usage? I think the real issue is JENKINS-35378
          Mark Hudson made changes -
          Link New: This issue relates to JENKINS-35378 [ JENKINS-35378 ]

          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.

          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.
          Andrew Bayer made changes -
          Resolution New: Won't Fix [ 2 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

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

              Created:
              Updated:
              Resolved: