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

echo step prints null when passed a non-String (was: cannot access envVars from RunWrapper)

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • workflow-cps-plugin
    • None
    • Jenkins 1.609.1
      workflow 1.8

    Description

      Hello,

      in Jenkins, I have two jobs:

      • one freestyle named foo, which calls a shell script which does echo $BUILD_ID
      • one workflow job

      When trigerring the job foo from the workflow, it is not possible to get the env vars the build had. For example, if I do

      def foo = build 'foo'
      echo foo.buildVariables
      echo foo.rawBuild.envVars
      

      Then I only get null. However, it is possible, from the script console to get those variables using

      def build = Jenkins.getInstance().getItemByFullName("foo").getBuildByNumber(6)
      build.getEnvVars()
      

      I get

      Result: {BUILD_DISPLAY_NAME=#6, BUILD_ID=6, BUILD_NUMBER=6, BUILD_TAG=jenkins-foo-6, BUILD_URL=http://localhost:8080/job/foo/6/, CLASSPATH=, HUDSON_HOME=/****/jenkins-home, HUDSON_SERVER_COOKIE=****, HUDSON_URL=http://localhost:8080/, JENKINS_HOME=/****/jenkins-home, JENKINS_SERVER_COOKIE=****, JENKINS_URL=http://localhost:8080/, JOB_NAME=foo, JOB_URL=http://localhost:8080/job/foo/, WORKSPACE=/****/jenkins-home/jobs/foo/workspace}
      

      The call to foo.getBuildVariables() return an empty map, but not null, as it is in the workflow.

      The workflow is not sandboxed so the foo.rawBuild is a Run object as in the script console. The two code should return the exact same result, don't you think?

      Attachments

        Issue Links

          Activity

            alecharp Adrien Lecharpentier created issue -
            jglick Jesse Glick made changes -
            Field Original Value New Value
            Summary It is not possible to access the build env vars from a RunWrapper echo step prints null when passed a non-String (was: It is not possible to access the build env vars from a RunWrapper)
            jglick Jesse Glick made changes -
            Summary echo step prints null when passed a non-String (was: It is not possible to access the build env vars from a RunWrapper) echo step prints null when passed a non-String (was: cannot access envVars from a RunWrapper)
            jglick Jesse Glick made changes -
            Summary echo step prints null when passed a non-String (was: cannot access envVars from a RunWrapper) echo step prints null when passed a non-String (was: cannot access envVars from RunWrapper)
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 163688 ] JNJira + In-Review [ 181338 ]
            abayer Andrew Bayer made changes -
            Component/s pipeline-general [ 21692 ]
            abayer Andrew Bayer made changes -
            Component/s workflow-plugin [ 18820 ]
            jglick Jesse Glick made changes -
            Link This issue is related to JENKINS-33217 [ JENKINS-33217 ]
            jglick Jesse Glick made changes -
            Component/s workflow-cps-plugin [ 21713 ]
            Component/s pipeline [ 21692 ]

            People

              jglick Jesse Glick
              alecharp Adrien Lecharpentier
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: