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

Path is not getting set correctly in pipeline when there is a variable present

XMLWordPrintable

      After upgrading to latest Pipeline version and it's dependencies (we also upgraded the blue ocean plugins but don't think that caused an issue here), we noticed that the PATH was not getting set in our Jenkins Pipeline Jobs. After debugging found that if I set PATH to a string inside the "environment" section, as such:

       

          environment

      {         PATH="/a/new/bin:$PATH"    }

       

      The PATH was updated successfully without any issues. However if I introduce a variable, the path does not get updated, and defaults to what is on the agent that runs the job. Example:

      pipeline

      {       agent

      {  label 'docker'    }

          environment {
              PATH="/a/new/bin:${env.SCM_HOME}:$PATH"
              SCM_HOME="${env.SCM_HOME}"
         }
        stages {
          stage ('build') {
            steps

      {         echo "PATH=$PATH"         echo "SCM_HOME=$SCM_HOME"       }

          }
        }
      }

       

      OUTPUT:

       
      [Pipeline] {

      [Pipeline] withEnv

      [Pipeline] {

      [Pipeline] stage

      [Pipeline] { (build)

      [Pipeline] echoPATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin

      [Pipeline] echoSCM_HOME=/usr/local/bin/scmtools/

      [Pipeline] }

      [Pipeline] // stage

      [Pipeline] }

      [Pipeline] // withEnv

      [Pipeline] }

      [Pipeline] // node

      [Pipeline] End of PipelineFinished: SUCCESS
       

       

      Notice that SCM_HOME resolves fine outside of PATH and that /a/new/bin was not added to the path. However if I drop the variable it will set PATH fine.

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

              Created:
              Updated:
              Resolved: