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

Method calls in environment block are always null

    Details

    • Similar Issues:
    • Epic Link:

      Description

      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.

        Attachments

          Issue Links

            Activity

            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/EnvironmentTest.java
            pipeline-model-definition/src/test/resources/nonLiteralEnvironment.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/e2001b6a7907bec8298faeafa16a88c7bcaa1ff4
            Log:
            JENKINS-43681 Just verify that a simple expression works as well

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/EnvironmentTest.java pipeline-model-definition/src/test/resources/nonLiteralEnvironment.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/e2001b6a7907bec8298faeafa16a88c7bcaa1ff4 Log: JENKINS-43681 Just verify that a simple expression works as well
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/EnvironmentTest.java
            pipeline-model-definition/src/test/resources/nonLiteralEnvironment.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/595bf3379ed67a962902084149e1bf81cb437056
            Log:
            Merge pull request #154 from abayer/jenkins-43681-verify-test

            JENKINS-43681 Just verify that a simple expression works as well

            Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/a185431a9658...595bf3379ed6

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/EnvironmentTest.java pipeline-model-definition/src/test/resources/nonLiteralEnvironment.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/595bf3379ed67a962902084149e1bf81cb437056 Log: Merge pull request #154 from abayer/jenkins-43681-verify-test JENKINS-43681 Just verify that a simple expression works as well Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/a185431a9658...595bf3379ed6
            Hide
            abayer Andrew Bayer added a comment -

            Christopher Smith Ping - I'm trying to clean up tickets. Is this still a problem for you?

            Show
            abayer Andrew Bayer added a comment - Christopher Smith Ping - I'm trying to clean up tickets. Is this still a problem for you?
            Hide
            abayer Andrew Bayer added a comment -

            This definitely works with the JENKINS-42753 PR in any form I could come up with, even if it isn't working in Declarative 1.1.x. So worst case, it's fixed in the upcoming Declarative 1.2 release.

            Show
            abayer Andrew Bayer added a comment - This definitely works with the JENKINS-42753 PR in any form I could come up with, even if it isn't working in Declarative 1.1.x. So worst case, it's fixed in the upcoming Declarative 1.2 release.
            Hide
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

            Show
            bitwiseman Liam Newman added a comment - Bulk closing resolved issues.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: