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

Method calls in environment block are always null

      I am attempting to calculate a value to be used in a few different places in my pipeline. The definition is in a method (in a global library, but I have identical behavior with an inline method).

      environment {
        MY_VAR = calculate()
      }

      In this scenario, MY_VAR is always null--even if the RHS is the GString {{ "${1+2}" }}! In fact, credentials() is the only non-compile-time-constant expression that I can get to evaluate to non-null.

      I expected the values in the environment block to be evaluated on the master when the pipeline is started up and then injected appropriately.

          [JENKINS-43681] Method calls in environment block are always null

          Christopher Smith created issue -
          Andrew Bayer made changes -
          Component/s New: pipeline-model-definition-plugin [ 21706 ]
          Component/s Original: pipeline [ 21692 ]
          Andrew Bayer made changes -
          Assignee New: Andrew Bayer [ abayer ]
          Andrew Bayer made changes -
          Remote Link New: This issue links to "PR #154 (Web Link)" [ 16228 ]
          Andrew Bayer made changes -
          Issue Type Original: Improvement [ 4 ] New: Bug [ 1 ]
          Andrew Bayer made changes -
          Labels New: declarative-variable-and-method-resolution
          James Dumay made changes -
          Epic Link New: JENKINS-45422 [ 183590 ]
          Andrew Bayer made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          Liam Newman made changes -
          Status Original: Resolved [ 5 ] New: Closed [ 6 ]

            abayer Andrew Bayer
            chrylis Christopher Smith
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: