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

Multi-branch pipelines do not interpolate platform environment variables into Jenkins global environment variables

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None

    Description

      Did not test this on any previous versions of Jenkins/Plugins

      Steps:

      1. Install Maven and Gradle using SDKMAN (http://sdkman.io)
      2. Install NodeJS using NVM (https://github.com/creationix/nvm)
      3. Add a global environment variable PATH that appends the tool paths (${PATH}:${HOME}/.nvm/versions/node/v6.11.1/bin:${HOME}/.sdkman/candidates/maven/current/bin:...)
      4. Create a multi-branch (Jenkinsfile) build that executes a shell command using sh

      Result:

      [Pipeline] sh
      [***JOB***-TGZIHGC5MANL6BRDMLV3HGPUPVWZW5TYQK3AXDKNEHCXHUAIDQNQ] Running shell script
      nohup: failed to run command ‘sh’: No such file or directory
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node
      

      If I change the global environment variable to include /bin, /usr/bin etc. instead of using ${PATH} and dump out the value of ${PATH} during the build, I see the following:

      [Pipeline] {
      [Pipeline] sh
      [***JOB***-TGZIHGC5MANL6BRDMLV3HGPUPVWZW5TYQK3AXDKNEHCXHUAIDQNQ] Running shell script
      + echo '${HOME}/.sdkman/candidates/maven/current/bin:${HOME}/.sdkman/candidates/gradle/current/bin:${HOME}/.nvm/versions/node/v6.11.1/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin'
      ${HOME}/.sdkman/candidates/maven/current/bin:${HOME}/.sdkman/candidates/gradle/current/bin:${HOME}/.nvm/versions/node/v6.11.1/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin
      

      This suggests that the platform environment variables are not being interpolated into the Jenkins global environment variables.  Other Jenkins global environment variables do seem to be expanded however (such as if I set ${MAVEN_HOME} and use it in ${PATH}).

      If I dump out ${PATH} from a non-pipeline Freestyle project shell step, I get the expected value (including both ${HOME} and ${PATH} expanded fully).

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gkrupa Gerard Krupa
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: