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

Global EnvironmentVariableNodeProperty does not show up in Pipeline unless in a node {...} block

      If you have a global environment variable set (let's say SOME_VAR="hi" for this example) in the Jenkins global configuration, that variable will not be in the Pipeline environment until you enter a node block, albeit any node block. So, for example,

      echo "SOME_VAR outside is ${env.SOME_VAR}"
      node {
        echo "SOME_VAR inside is ${env.SOME_VAR}"
      }

      will output

      SOME_VAR outside is null
      SOME_VAR inside is hi

      So I think WorkflowRun needs to include Jenkins.getInstance().getGlobalNodeProperties() when creating its initial environment.

          [JENKINS-43396] Global EnvironmentVariableNodeProperty does not show up in Pipeline unless in a node {...} block

          Andrew Bayer added a comment -

          Andrew Bayer added a comment - PR up for this at  https://github.com/jenkinsci/workflow-job-plugin/pull/43

          Jesse Glick added a comment -

          I feel like this is a duplicate but I am not sure of what.

          Jesse Glick added a comment - I feel like this is a duplicate but I am not sure of what.

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java
          src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunTest.java
          http://jenkins-ci.org/commit/workflow-job-plugin/3fd2761b483020f577b02e55ef0b766815285a95
          Log:
          [FIXED JENKINS-43396] Global NodePropertys should be in environment

          They currently show up once you enter a node block, but not for things
          outside node blocks. This fixes that by adding them to
          WorkflowRun.getEnvironment(listener).

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunTest.java http://jenkins-ci.org/commit/workflow-job-plugin/3fd2761b483020f577b02e55ef0b766815285a95 Log: [FIXED JENKINS-43396] Global NodePropertys should be in environment They currently show up once you enter a node block, but not for things outside node blocks. This fixes that by adding them to WorkflowRun.getEnvironment(listener).

          jglick: i think #40455 is a duplicate of this one

           

          Christoph Vogtländer added a comment - jglick : i think #40455 is a duplicate of this one  

            abayer Andrew Bayer
            abayer Andrew Bayer
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: