[JIRA] (JENKINS-41339) Environment variables referencing other variables broken

177 views
Skip to first unread message

jtatum@gmail.com (JIRA)

unread,
Jan 23, 2017, 3:46:01 PM1/23/17
to jenkinsc...@googlegroups.com
James Tatum created an issue
 
Jenkins / Bug JENKINS-41339
Environment variables referencing other variables broken
Issue Type: Bug Bug
Assignee: Unassigned
Components: workflow-durable-task-step-plugin
Created: 2017/Jan/23 8:45 PM
Environment: Jenkins 2.41
Durable task plugin 1.13
Centos 6.5
Priority: Major Major
Reporter: James Tatum

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
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

jtatum@gmail.com (JIRA)

unread,
Jan 23, 2017, 3:51:01 PM1/23/17
to jenkinsc...@googlegroups.com
James Tatum commented on Bug JENKINS-41339
 
Re: Environment variables referencing other variables broken

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@gmail.com (JIRA)

unread,
Jan 23, 2017, 5:50:20 PM1/23/17
to jenkinsc...@googlegroups.com

dbeck@cloudbees.com (JIRA)

unread,
Jan 23, 2017, 6:04:02 PM1/23/17
to jenkinsc...@googlegroups.com
Daniel Beck commented on Bug JENKINS-41339
 
Re: Environment variables referencing other variables broken

Cannot reproduce on a pristine installation of Jenkins 2.0.

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?

dbeck@cloudbees.com (JIRA)

unread,
Jan 23, 2017, 6:06:01 PM1/23/17
to jenkinsc...@googlegroups.com
Daniel Beck edited a comment on Bug JENKINS-41339
Cannot reproduce on a pristine installation of Jenkins 2. 0 40 with current releases of Pipeline and its dependencies (installed 10 minutes ago) .

{noformat}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

{noformat}


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

jtatum@gmail.com (JIRA)

unread,
Jan 23, 2017, 8:20:05 PM1/23/17
to jenkinsc...@googlegroups.com

No envinject. This is a pretty vanilla Jenkins install, just pipeline and blue ocean. Here's the full list of installed plugins: https://gist.github.com/jtatum/3490869585f209b453ddc90ff85b7936

jtatum@gmail.com (JIRA)

unread,
Jan 23, 2017, 8:31:03 PM1/23/17
to jenkinsc...@googlegroups.com
James Tatum edited a comment on Bug JENKINS-41339
No envinject. This is a pretty vanilla Jenkins install, just pipeline and blue ocean. Here's the full list of For fun, I created a digitalocean droplet, installed plugins jenkins, and reproduced it. http : https: // gist 138 . github 197 . com 195.70:8080 / jtatum/3490869585f209b453ddc90ff85b7936

jtatum@gmail.com (JIRA)

unread,
Jan 23, 2017, 8:32:01 PM1/23/17
to jenkinsc...@googlegroups.com
James Tatum edited a comment on Bug JENKINS-41339
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/

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

jtatum@gmail.com (JIRA)

unread,
Jan 23, 2017, 8:38:02 PM1/23/17
to jenkinsc...@googlegroups.com
James Tatum edited a comment on Bug JENKINS-41339
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

apazga@gmail.com (JIRA)

unread,
Jan 24, 2017, 5:57:02 AM1/24/17
to jenkinsc...@googlegroups.com
Abel Paz commented on Bug JENKINS-41339

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.

dbeck@cloudbees.com (JIRA)

unread,
Jan 24, 2017, 6:00:01 AM1/24/17
to jenkinsc...@googlegroups.com

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

Will investigate more later.

opitz@pluspol.info (JIRA)

unread,
Jan 24, 2017, 7:10:01 AM1/24/17
to jenkinsc...@googlegroups.com

opitz@pluspol.info (JIRA)

unread,
Jan 24, 2017, 7:12:01 AM1/24/17
to jenkinsc...@googlegroups.com

k.keppens@ugent.be (JIRA)

unread,
Jan 25, 2017, 3:16:05 AM1/25/17
to jenkinsc...@googlegroups.com
Kristof Keppens commented on Bug JENKINS-41339
 
Re: Environment variables referencing other variables broken

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.

dbeck@cloudbees.com (JIRA)

unread,
Jan 26, 2017, 9:05:03 AM1/26/17
to jenkinsc...@googlegroups.com

Reproduced on 2.19.4 with newest Pipeline plugins.

If and only if I set a custom PATH for the node the sh step runs on, the PATH gets messed up. Does not affect freestyle jobs, and the Pipeline job works again immediately when removing the custom PATH.

Workaround: Set the PATH as env var for the invoking process. In the case of SSH slaves, could probably be a launch command prefix.

Sending bat signal to Jesse Glick.

dbeck@cloudbees.com (JIRA)

unread,
Jan 26, 2017, 9:14:03 AM1/26/17
to jenkinsc...@googlegroups.com
Daniel Beck edited a comment on Bug JENKINS-41339
Reproduced on 2.19.4 with newest Pipeline plugins.

If and only if I set a custom PATH for the node the {{sh}} step runs on, the PATH gets messed up. Does not affect freestyle jobs, and the Pipeline job works again immediately when removing the custom PATH.

Workaround (untested) : Set the PATH as env var for the invoking invoked Jenkins master/slave process rather than through Jenkins . In the case of SSH slaves, could probably be a launch command prefix. Downgrading reportedly also works.

Sending bat signal to [~jglick].

dbeck@cloudbees.com (JIRA)

unread,
Jan 26, 2017, 9:22:05 AM1/26/17
to jenkinsc...@googlegroups.com
Daniel Beck edited a comment on Bug JENKINS-41339
Reproduced on 2.19.4 with newest Pipeline plugins.

If and only if I set a custom PATH for the node the {{sh}} step runs on, the PATH gets messed up. Does not affect freestyle jobs, and the Pipeline job works again immediately when removing the custom PATH.

Workaround (untested) Workarounds :

*
Set the PATH as env var for the invoked Jenkins master/slave process rather than through Jenkins. In the case of SSH slaves, could probably be a launch command prefix. (untested)
* Set e.g. the {{PATH+whatever}} env var instead, and just set the _addition_ to the PATH (e.g. {{/whatever}}). This will have the same effect as setting {{PATH}} to {{/whatever:$PATH}}. That's how Jenkins plugins add e.g. tools to the path. (confirmed)
*
Downgrading reportedly also works.


Sending bat signal to [~jglick].

jglick@cloudbees.com (JIRA)

unread,
Jan 26, 2017, 10:09:03 AM1/26/17
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Jan 26, 2017, 10:09:06 AM1/26/17
to jenkinsc...@googlegroups.com
Jesse Glick started work on Bug JENKINS-41339
 
Change By: Jesse Glick
Status: Open In Progress

jglick@cloudbees.com (JIRA)

unread,
Jan 26, 2017, 10:12:05 AM1/26/17
to jenkinsc...@googlegroups.com
Jesse Glick commented on Bug JENKINS-41339
 
Re: Environment variables referencing other variables broken

Using the PATH+WHATEVER=/something/bin syntax works even in 1.13, and is the syntax documented in inline help as what you should use.

I will check if the nonrecommended mode can be supported without regressing JENKINS-40734.

jglick@cloudbees.com (JIRA)

unread,
Jan 26, 2017, 12:40:02 PM1/26/17
to jenkinsc...@googlegroups.com

jtatum@gmail.com (JIRA)

unread,
Jan 26, 2017, 3:24:02 PM1/26/17
to jenkinsc...@googlegroups.com
James Tatum commented on Bug JENKINS-41339
 
Re: Environment variables referencing other variables broken

Hmm, this is the in-line help for global environment variables:

These key-value pairs apply for every build on every node. They can be used in 
Jenkins' configuration (as $key or ${key}) and will be added to the environment 
for processes launched from the build.

I see the + syntax is mentioned in the node environment variable settings. I guess it needs to be copied over, assuming it also works globally. Also this is prepend only?

jtatum@gmail.com (JIRA)

unread,
Jan 26, 2017, 3:52:02 PM1/26/17
to jenkinsc...@googlegroups.com
James Tatum edited a comment on Bug JENKINS-41339
Hmm, this is the in-line help for global environment variables:

{noformat}

These key-value pairs apply for every build on every node. They can be used in
Jenkins' configuration (as $key or ${key}) and will be added to the environment
for processes launched from the build.
{noformat}

I see the + syntax is mentioned in the node environment variable settings. I guess it needs to be copied over, assuming it also works globally.
Also I wrote JENKINS-41492 for this is prepend only? update.

jglick@cloudbees.com (JIRA)

unread,
Jan 30, 2017, 5:37:02 PM1/30/17
to jenkinsc...@googlegroups.com

nowayride@icloud.com (JIRA)

unread,
Feb 3, 2017, 4:27:04 PM2/3/17
to jenkinsc...@googlegroups.com
Will Normand commented on Bug JENKINS-41339
 
Re: Environment variables referencing other variables broken

Jesse Glick how would you set PATH to something like:

$JAVA_HOME/bin:/opt/tools/bin:/opt/nodejs/bin:/opt/python/bin:/opt/composer/bin:/opt/go/$

{GOVERSION}

/go/bin:$PATH

This worked in 1.12 but I can't find the right combination of the plus sign syntax to get all of these variables to line up. The inline help isn't terribly clear. Even then, if I am reading this right I will have to create additional environment variables so I can use GOVERSION in the middle of the path?

nfalco79@hotmail.com (JIRA)

unread,
Feb 9, 2017, 11:53:05 AM2/9/17
to jenkinsc...@googlegroups.com

me too.

Every time I put a sh step in a pipeline project it break with same error.

node {
    echo '$PATH'
    sh 'ls'
}

The PATH environment variable seems to be corrupted.

Started by user Guest
[Pipeline] node
Running on master in /var/lib/jenkins/jobs/xyz/workspace
[Pipeline] {
[Pipeline] echo
$PATH
[Pipeline] sh
[workspace] 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

nfalco79@hotmail.com (JIRA)

unread,
Feb 9, 2017, 11:54:02 AM2/9/17
to jenkinsc...@googlegroups.com
Nikolas Falco edited a comment on Bug JENKINS-41339
me too.

Every time I put a sh step in a pipeline project it break with same error.
{code}
node {
    echo
' " $PATH ' "
    sh 'ls'
}
{code}

The PATH environment variable seems to be corrupted.

{noformat}

Started by user Guest
[Pipeline] node
Running on master in /var/lib/jenkins/jobs/xyz/workspace
[Pipeline] {
[Pipeline] echo
$PATH :/usr/local/bin
[Pipeline] sh
[workspace] 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
{noformat}

octaviantuchila14@gmail.com (JIRA)

unread,
Feb 9, 2017, 1:06:04 PM2/9/17
to jenkinsc...@googlegroups.com

Daniel Beckham

What does this mean?

Set e.g. the PATH+whatever env var instead, and just set the addition to the PATH (e.g. /whatever). This will have the same effect as setting PATH to /whatever:$PATH. That's how Jenkins plugins add e.g. tools to the path. (confirmed)

Can you please give an example?

octaviantuchila14@gmail.com (JIRA)

unread,
Feb 9, 2017, 1:07:02 PM2/9/17
to jenkinsc...@googlegroups.com
Octavian Tuchila edited a comment on Bug JENKINS-41339
[~ dbeckham danielbeck ]


What does this mean?

_Set e.g. the PATH+whatever env var instead, and just set the addition to the PATH (e.g. /whatever). This will have the same effect as setting PATH to /whatever:$PATH. That's how Jenkins plugins add e.g. tools to the path. (confirmed)_



Can you please give an example?

dbeck@cloudbees.com (JIRA)

unread,
Feb 9, 2017, 1:14:02 PM2/9/17
to jenkinsc...@googlegroups.com

Octavian Tuchila See the two comments after mine. Jesse provides an example, James links to an issue explaining where it's documented.

octaviantuchila14@gmail.com (JIRA)

unread,
Feb 9, 2017, 3:39:06 PM2/9/17
to jenkinsc...@googlegroups.com

Daniel Beck

Sorry to bother you, but I didn't understand his example either.

So let's assume I want to add /usr/local/bin/node to the path.

Normally, I would add it like:

PATH=/usr/local/bin/node:$PATH

However, now I would have to add it like this?

_
PATH=$PATH+/usr/local/bin/node_

Is that correct?

octaviantuchila14@gmail.com (JIRA)

unread,
Feb 9, 2017, 3:39:10 PM2/9/17
to jenkinsc...@googlegroups.com
Octavian Tuchila edited a comment on Bug JENKINS-41339
[~danielbeck]


Sorry to bother you, but I didn't understand his example either.

So let's assume I want to add _/usr/local/bin/node_ to the path.


Normally, I would add it like:

_PATH=/usr/local/bin/node:$PATH_

However, now I would have to add it like this?

_
PATH
_PATH =$PATH+/usr/local/bin/node_

Is that correct?

octaviantuchila14@gmail.com (JIRA)

unread,
Feb 9, 2017, 3:40:02 PM2/9/17
to jenkinsc...@googlegroups.com
Octavian Tuchila edited a comment on Bug JENKINS-41339
[~danielbeck]

Sorry to bother you, but I didn't understand his example either.

So let's assume I want to add _/usr/local/ bin/node_ bin_ to the path.


Normally, I would add it like:

_PATH=/usr/local/bin /node :$PATH_

However, now I would have to add it like this?

_PATH=$PATH+/usr/local/bin/node_

Is that correct?

octaviantuchila14@gmail.com (JIRA)

unread,
Feb 9, 2017, 3:40:06 PM2/9/17
to jenkinsc...@googlegroups.com
Octavian Tuchila edited a comment on Bug JENKINS-41339
[~danielbeck]

Sorry to bother you, but I didn't understand his example either.

So let's assume I want to add _/usr/local/bin_ to the path.


Normally, I would add it like:

_PATH=/usr/local/bin:$PATH_

However, now I would have to add it like this?

_PATH=$PATH+/usr/local/bin/ node_ _

Is that correct?

octaviantuchila14@gmail.com (JIRA)

unread,
Feb 9, 2017, 3:42:02 PM2/9/17
to jenkinsc...@googlegroups.com
Octavian Tuchila edited a comment on Bug JENKINS-41339
[~danielbeck]

Sorry to bother you, but I didn't understand his example either.

So let's assume I want to add _/usr/local/bin_ to the path.

Normally, I would add it like:

_PATH=/usr/local/bin:$PATH_

However, now I would have to add it like this ? :

_PATH=$PATH+/usr/local/bin/_

Is that correct?

octaviantuchila14@gmail.com (JIRA)

unread,
Feb 9, 2017, 3:50:05 PM2/9/17
to jenkinsc...@googlegroups.com
Octavian Tuchila edited a comment on Bug JENKINS-41339
[~danielbeck]

Sorry to bother you, but I didn't understand his example either.

So let's assume I want to add _/usr/local/ lib/node_modules/npm/ bin_ to the path.


Normally, I would add it like:

_PATH=/usr/local/ lib/node_modules/npm/ bin:$PATH_

However, now I would have to add it like this:

_PATH
=$PATH + bin= /usr/local/ bin lib / _ node_modules/npm/bin_

Is that correct?

octaviantuchila14@gmail.com (JIRA)

unread,
Feb 9, 2017, 3:50:09 PM2/9/17
to jenkinsc...@googlegroups.com
Octavian Tuchila edited a comment on Bug JENKINS-41339
[~danielbeck]

Sorry to bother you, but I didn't understand his example either.

So let's assume I want to add _/usr/local/lib/node_modules/npm/bin_ to the path.


Normally, I would add it like:

_PATH=/usr/local/lib/node_modules/npm/bin:$PATH_

However, now I would have to add it like this:

_PATH+ bin npm =/usr/local/lib/node_modules/npm/bin_

Is that correct?

octaviantuchila14@gmail.com (JIRA)

unread,
Feb 10, 2017, 7:12:05 AM2/10/17
to jenkinsc...@googlegroups.com
Octavian Tuchila edited a comment on Bug JENKINS-41339
[~danielbeck]

Sorry to bother you, but I didn't understand his example either.

So let's assume I want to add _/usr/local/lib/node_modules/npm/bin_ to the path.

Normally, I would add it like:

_PATH=/usr/local/lib/node_modules/npm/bin:$PATH_

However, now I would have to add it like this:

_PATH+npm=/usr/local/lib/node_modules/npm/bin_

Is that correct?

[~jglick]?

dbeck@cloudbees.com (JIRA)

unread,
Feb 10, 2017, 7:31:04 AM2/10/17
to jenkinsc...@googlegroups.com

That's correct.

PATH+whatever=value means that value with be added to the beginning of PATH, separated by the path separator char.

John.Mellor@esentire.com (JIRA)

unread,
Feb 10, 2017, 3:55:04 PM2/10/17
to jenkinsc...@googlegroups.com

I do not see a 1.14 plugin available, so I assume that this fix is in fact not released yet. As per the conversation in https://groups.google.com/forum/#!msg/jenkinsci-users/LN057YL_Xis/wyIBfAbfCwAJ, I downgraded the durable tasks plugin from 1.13 to 1.12 and the pipeline plugins to try to work around this killer bug. Interestingly, this apparently does not require a reboot (not sure if that is another bug or not). However, after reverting the plugin, I still cannot run simple shell commands as part of the pipeline. How do I get back to working pipelines?

dbeck@cloudbees.com (JIRA)

unread,
Feb 10, 2017, 4:01:05 PM2/10/17
to jenkinsc...@googlegroups.com

How do I get back to working pipelines?

Try actually restarting. Downgrading needs a restart.

John.Mellor@esentire.com (JIRA)

unread,
Feb 11, 2017, 11:20:02 AM2/11/17
to jenkinsc...@googlegroups.com

Confirmed, restart needed after downgrading.

jglick@cloudbees.com (JIRA)

unread,
Feb 15, 2017, 12:03:03 PM2/15/17
to jenkinsc...@googlegroups.com

how would you set PATH to something like

Fix your launcher, ~/.profile, etc. Avoid doing this from Jenkins.

The fix was released in workflow-durable-task-step.

opitz@pluspol.info (JIRA)

unread,
Feb 16, 2017, 3:35:03 AM2/16/17
to jenkinsc...@googlegroups.com

If PATH+whatever=value prepends how do I append something to PATH?

dbeck@cloudbees.com (JIRA)

unread,
Feb 16, 2017, 7:39:02 AM2/16/17
to jenkinsc...@googlegroups.com

how do I append something to PATH

I don't think there's a good answer right now. What's the use case?

jglick@cloudbees.com (JIRA)

unread,
Feb 16, 2017, 12:24:04 PM2/16/17
to jenkinsc...@googlegroups.com

Again I do not recommend using Jenkins to modify system environment variables like PATH on nodes to begin with.

jamesdh@gmail.com (JIRA)

unread,
Feb 16, 2017, 1:47:03 PM2/16/17
to jenkinsc...@googlegroups.com

Part of the problem with the "downgrade" workaround is that if you've updated other plugins that depend on 1.13, those other plugins then do not get reloaded on restart, and therefore you cannot downgrade them in the plugin manager.

Or am I missing something?

jamesdh@gmail.com (JIRA)

unread,
Feb 16, 2017, 1:47:05 PM2/16/17
to jenkinsc...@googlegroups.com
hardwickj edited a comment on Bug JENKINS-41339
Part of the problem with the "downgrade" workaround is that if you've updated other plugins that depend on durable-task: 1.13, those other plugins then do not get reloaded on restart, and therefore you cannot downgrade them in the plugin manager.

Or am I missing something?

jamesdh@gmail.com (JIRA)

unread,
Feb 16, 2017, 2:04:01 PM2/16/17
to jenkinsc...@googlegroups.com

It especially doesn't help when archives.jenkins-ci.org goes down and then you're just stuck.

gstock.public@gmail.com (JIRA)

unread,
Feb 16, 2017, 3:10:02 PM2/16/17
to jenkinsc...@googlegroups.com
aflat commented on Bug JENKINS-41339

@jglick you may not recommend it, but sometimes it is almost necessary. Getting AIX/HPUX/Solaris to do a git clone, or just running a jenkins slave over ssh without setting the path can be difficult. You can try to set the shell profile correctly, but java can do screwy things with that as well, so you have to set the path in the java process, not just the shell to get it to run. Aix is probably the worst in this case.

jglick@cloudbees.com (JIRA)

unread,
Feb 16, 2017, 5:00:06 PM2/16/17
to jenkinsc...@googlegroups.com

You do not need to downgrade anything. Upgrade workflow-durable-task-step.

jamesdh@gmail.com (JIRA)

unread,
Feb 16, 2017, 6:46:04 PM2/16/17
to jenkinsc...@googlegroups.com

That doesn't actually fix it, it just spits out a warning regarding this issue and fails the job.

jglick@cloudbees.com (JIRA)

unread,
Feb 16, 2017, 7:10:01 PM2/16/17
to jenkinsc...@googlegroups.com

Well I have test coverage demonstrating the fix working at least in the case I was able to reproduce based on initial comments. Your situation may be a different bug.

Again, if you must adjust PATH from node properties—rather than, say, fixing your computer setup, or setting environment variables for the whole agent JVM in the launcher—prefer the documented and supported PATH+SOMETHING=/something syntax.

vivek.pandey@gmail.com (JIRA)

unread,
Nov 15, 2018, 5:22:03 PM11/15/18
to jenkinsc...@googlegroups.com
Vivek Pandey updated an issue
 
Jenkins / Bug JENKINS-41339
Change By: Vivek Pandey
Labels: blue-pipeline-scrub regression triaged-2018-11
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

tobin.davis@meghcomputing.com (JIRA)

unread,
Dec 12, 2018, 6:03:04 PM12/12/18
to jenkinsc...@googlegroups.com
Tobin Davis commented on Bug JENKINS-41339
 
Re: Environment variables referencing other variables broken

I am really confused by all of this.

First, I'm running 2.138.2 LTS (I know, I need to update), with all of the latests plugin version for pipeline (and no EnvInject plugin).  I have tried the following, with no success:

1st:

environment {
  DCP_VERSION = "1.2-alpha"
  DCP_LOC = "/opt/dcp/${DCP_VERSION}"
  QUARTUS_HOME = "/opt/inteldevstack/intelFPGA_pro/quartus" 
  MTI_HOME = "/opt/altera/17.1/modelsim_ase"
  TBB_HOME = "/opt/intel/tbb"
  PATH = "${MTI_HOME}/linux:${MTI_HOME}/bin:${QUARTUS_HOME}/bin:${DCP_LOC}/bin:${PATH}"
  LD_LIBRARY_PATH = '${LD_LIBRARY_PATH}:${TBB_HOME}/lib/intel64_lin/gcc4.7'
}

Produced this error:

nohup: failed to run command 'sh': No such file or directory

2nd (based on googling the sh command error)

environment {
  DCP_VERSION = "1.2-alpha"
  DCP_LOC = "/opt/dcp/${DCP_VERSION}"
  QUARTUS_HOME = "/opt/inteldevstack/intelFPGA_pro/quartus" 
  MTI_HOME = "/opt/altera/17.1/modelsim_ase"
  TBB_HOME = "/opt/intel/tbb"
  PATH+EXTRA = "${MTI_HOME}/linux:${MTI_HOME}/bin:${QUARTUS_HOME}/bin:${DCP_LOC}/bin"
  LD_LIBRARY_PATH = '${LD_LIBRARY_PATH}:${TBB_HOME}/lib/intel64_lin/gcc4.7'
}

Now I get this error:
(PATH + EXTRA) is a binary expression, but it should be a variable expression at line: 11 column: 19. File: WorkflowScript @ line 11, column 19.
PATH+EXTRA="${MTI_HOME}/linux:${MTI_HOME}/bin:${QUARTUS_HOME}/bin:${DCP_LOC}/bin"

Note that neither of these solutions are actually documented in the pipeline guide (https://jenkins.io/doc/book/pipeline/syntax/), and BOTH options are fully acceptable and copied from the built-in syntax generator.

So, what is the right way to do this? I can't set global paths as a lot of these paths change depending on the job (for example, MTI_HOME will change depending on simulator used - future script development task)

tobin.davis@meghcomputing.com (JIRA)

unread,
Dec 12, 2018, 8:32:03 PM12/12/18
to jenkinsc...@googlegroups.com
Tobin Davis edited a comment on Bug JENKINS-41339
Note that neither of these solutions are actually documented in the pipeline guide ( [ https://jenkins.io/doc/book/pipeline/syntax/ ] ), and BOTH options are fully acceptable and copied from the built-in syntax generator.


So, what is the right way to do this?  I can't set global paths as a lot of these paths change depending on the job (for example, MTI_HOME will change depending on simulator used - future script development task)


 

Update:  I got around the first issue by setting Jenkins global shell to /bin/bash.  Not cross platform, but works for now.

jglick@cloudbees.com (JIRA)

unread,
Jan 11, 2019, 6:03:02 PM1/11/19
to jenkinsc...@googlegroups.com

Tobin Davis the PATH+EXTRA system works for Scripted Pipeline. If it does not work for Declarative, please file a separate RFE in pipeline-model-definition-plugin. Workaround would I guess be something like (untested)

environment {
  STUFF = "${MTI_HOME}/linux:${MTI_HOME}/bin:${QUARTUS_HOME}/bin:${DCP_LOC}/bin"
}
// …
steps {
  withEnv(["PATH+EXTRA=$STUFF"]) {
    sh 'whatever'
  }
}
Reply all
Reply to author
Forward
0 new messages