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

parameter with null value breaks global env variables

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • envinject-plugin, pipeline
    • None
    • Jenkins 2.140
      envinject-plugin 2.1.3
      pipeline 2.6

      I have a job that starts builds of several other jobs. These builds sometimes where started with some paramers that where null by mistake (bug in the script of the upstream job).
      Then global env vars where missing for one of the downstream jobs (not all of them).

      Pipeline script of the downstream job:
      paratext= "params: \n"
      params.each

      {paratext+= it.toString()+"\n"}

      println paratext

      println "env.TOOLS_BUILDSTART: "+env.TOOLS_BUILDSTART
      def envVars = Jenkins.instance.getGlobalNodeProperties()[0].getEnvVars()
      println "envVars: "+envVars

      Output when started correctly:
      Replayed #115
      Running in Durability level: PERFORMANCE_OPTIMIZED
      [Pipeline] echo
      params:
      node=null
      BUILD_CLEANUP=false
      VERSION_OVERRIDE=
      GERRIT_TOPIC=JenkinsTest_ToolsBuildpy
      TOOLS_REFSPEC=refs/changes/29/15929/4
      GERRIT_REFSPEC=
      GERRIT_PROJECT=

      [Pipeline] echo
      env.TOOLS_BUILDSTART: /opt/ToolsBuildpy/JenkinsTools/build_start.gvy
      [Pipeline] echo
      envVars: [TOOLS_BUILDSTART:/opt/ToolsBuildpy/JenkinsTools/build_start.gvy, TOOLS_REFSPEC__unused-usingmaster:dummy]
      [Pipeline] End of Pipeline

      Output when started with null parameters:
      Replayed #120
      Running in Durability level: PERFORMANCE_OPTIMIZED
      [Pipeline] echo
      params:
      node=null
      BUILD_CLEANUP=false
      VERSION_OVERRIDE=
      GERRIT_TOPIC=JenkinsTest_ToolsBuildpynull
      TOOLS_REFSPEC=refs/changes/29/15929/4
      GERRIT_REFSPEC=null
      GERRIT_PROJECT=null

      [Pipeline] echo
      env.TOOLS_BUILDSTART: null
      [Pipeline] echo
      envVars: [TOOLS_BUILDSTART:/opt/ToolsBuildpy/JenkinsTools/build_start.gvy, TOOLS_REFSPEC__unused-usingmaster:dummy]
      [Pipeline] End of Pipeline

            Unassigned Unassigned
            romanz Roman Zwi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: