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

Environment variables referencing other variables broken

      This seems to have broken fairly recently. I have a global PATH environment variable defined in Jenkins as follows:

      PATH: /path/to/toolchain/bin:$PATH

      Freestyle jobs work with this. An older version of the durable task plugin also worked. After updating to the latest, this pipeline job:

      node('master', {
          echo 'env.PATH=' + env.PATH
          sh('env')
         })
      

      results in this output:

      [Pipeline] node
      Running on master in /var/lib/jenkins/workspace/pipeline bug
      [Pipeline] {
      [Pipeline] echo
      env.PATH=/path/to/toolchain/bin:$PATH
      [Pipeline] sh
      [pipeline bug] Running shell script
      nohup: failed to run command ‘sh’: No such file or directory
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      ERROR: script returned exit code -2
      Finished: FAILURE
      

          [JENKINS-41339] Environment variables referencing other variables broken

          James Tatum created issue -

          James Tatum added a comment -

          If I symlink /bin/sh to my toolchain path and change env to /bin/env, the output shows the shell using this path variable:

          PATH=/path/to/toolchain/bin:$PATH - just like the groovy output.

          James Tatum added a comment - If I symlink /bin/sh to my toolchain path and change env to /bin/env, the output shows the shell using this path variable: PATH=/path/to/toolchain/bin:$PATH - just like the groovy output.
          Andrew Bayer made changes -
          Assignee New: Jesse Glick [ jglick ]

          Daniel Beck added a comment - - edited

          Cannot reproduce on a pristine installation of Jenkins 2.40 with current releases of Pipeline and its dependencies (installed 10 minutes ago).

          Started by user admin
          [Pipeline] node
          Running on master in /Users/danielbeck/JENKINS-41339-Home/workspace/pipe
          [Pipeline] {
          [Pipeline] echo
          env.PATH=/Users/danielbeck/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/groovy/bin:/opt/X11/bin:/usr/local/MacGPG2/bin
          [Pipeline] sh
          [pipe] Running shell script
          + env
          …
          

          Let me guess, envinject is installed and you're doing something insane like undefining all node environment variables?

          Daniel Beck added a comment - - edited Cannot reproduce on a pristine installation of Jenkins 2.40 with current releases of Pipeline and its dependencies (installed 10 minutes ago). Started by user admin [Pipeline] node Running on master in /Users/danielbeck/JENKINS-41339-Home/workspace/pipe [Pipeline] { [Pipeline] echo env.PATH=/Users/danielbeck/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/groovy/bin:/opt/X11/bin:/usr/local/MacGPG2/bin [Pipeline] sh [pipe] Running shell script + env … Let me guess, envinject is installed and you're doing something insane like undefining all node environment variables?

          James Tatum added a comment - - edited

          No envinject. This is a pretty vanilla Jenkins install, just pipeline and blue ocean. For fun, I created a digitalocean droplet, installed jenkins, and reproduced it. http://138.197.195.70:8080/ (L/P jenkinsbug:jenkinsbug)

          Did you setup the path in the right place? Mine is under Manage Jenkins > Configure System > Global Properties > Environment variables

          James Tatum added a comment - - edited No envinject. This is a pretty vanilla Jenkins install, just pipeline and blue ocean. For fun, I created a digitalocean droplet, installed jenkins, and reproduced it. http://138.197.195.70:8080/ (L/P jenkinsbug:jenkinsbug) Did you setup the path in the right place? Mine is under Manage Jenkins > Configure System > Global Properties > Environment variables

          Abel Paz added a comment -

          Same happening here:

          • CentOS 7.1
          • Jenkins ver. 2.42
          • Durable Task plugin 1.13
          [workspace] Running shell script
          nohup: failed to run command ‘sh’: No such file or directory
          

          It happens with any shell script call.
          If I downgrade Durable Task plugin to 1.12 it, it works.

          Abel Paz added a comment - Same happening here: CentOS 7.1 Jenkins ver. 2.42 Durable Task plugin 1.13 [workspace] Running shell script nohup: failed to run command ‘sh’: No such file or directory It happens with any shell script call. If I downgrade Durable Task plugin to 1.12 it, it works.

          Daniel Beck added a comment -

          No, I did not specify a path in the global configuration, I missed that part.

          Will investigate more later.

          Daniel Beck added a comment - No, I did not specify a path in the global configuration, I missed that part. Will investigate more later.

          This seams to be an issue after JENKINS-40734

          Alexander Opitz added a comment - This seams to be an issue after JENKINS-40734
          Alexander Opitz made changes -
          Component/s New: durable-task-plugin [ 18622 ]

          I can reproduce this as well :

          Debian 8
          Jenkins 2.32.1
          Durable task plugin 1.13

          Reverting to durable task plugin 1.12 fixes the issue.

          Kristof Keppens added a comment - I can reproduce this as well : Debian 8 Jenkins 2.32.1 Durable task plugin 1.13 Reverting to durable task plugin 1.12 fixes the issue.

            Unassigned Unassigned
            jtatum James Tatum
            Votes:
            27 Vote for this issue
            Watchers:
            52 Start watching this issue

              Created:
              Updated: