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

Return map of environment variables of job in org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper

    Details

    • Similar Issues:

      Description

      With the Pipeline Plugin, I'd like a list of environment variables to be returned from the build result of a job (like you can already do with `duration` and `description`)

      For example,

      def e = build "test-env"
      echo "${e.environment.GIT_COMMIT}"
      echo "${e.environment.FOO}"
      

      I believe the fix is to add a whitelisted getEnvironment() method to the RunWrapper, similar to the one done in this merged PR here for JENKINS-36306

      The current fix is to access the environment variables is to access it via the rawBuild, however that needs to be explicitly whitelisted as RunWrapper.getRawBuild is blacklisted

      def e = build "test-env"
      echo "${e.rawBuild.environment.GIT_COMMIT}"
      

      Thanks

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                cam Cameron I
              • Votes:
                1 Vote for this issue
                Watchers:
                11 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: