Jenkins 1.607 - Environment Variables Stuck

358 views
Skip to first unread message

Varun Jain

unread,
Apr 24, 2015, 6:41:23 PM4/24/15
to jenkins...@googlegroups.com
Hey everyone.

I'm facing an issue where the environment variables seem stuck and un-updating when running tasks via Jenkins on Windows Slaves. Here are the steps I do to reproduce, and resolve the problem

1. Create new Node and set JUST the home directory
2. Run job with just "echo %PATH%"
3. Modify PATH, restart Jenkins Slave
4. Echo PATH via command line, outputs as the correct NEW Path
5. Run job with jenkins. OLD path is output

Resolution:
Delete and recreate slave

Thanks,
VJ

Jennifer Hofmeister

unread,
Apr 27, 2015, 8:57:23 AM4/27/15
to jenkins...@googlegroups.com

Hi Varun,

 

Does the slave run as a service? If not, it will probably just read the Jenkins service’s old PATH in case that one was not restarted after manipulation.

 

Best,

 

Jennifer

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3153e714-ee64-490c-b65e-c31812e76864%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Varun Jain

unread,
Apr 27, 2015, 2:17:07 PM4/27/15
to jenkins...@googlegroups.com, jennifer....@younicos.com
Hi Jennifer,

I've tried it as the service, the JNLP, and the java command line. All of which yielded the same results. I also did try restarting the service.

Thanks,
VJ

Simon Richter

unread,
Apr 27, 2015, 4:44:12 PM4/27/15
to jenkins...@googlegroups.com
Hi,

On 27.04.2015 14:57, Jennifer Hofmeister wrote:

> Does the slave run as a service? If not, it will probably just read the Jenkins service’s old PATH in case that one was not restarted after manipulation.

I have the same issue, I can even reboot the slave and the environment
stays the same (all variables, not just PATH).

It appears that new variables are taken over once when the slave starts,
but then remain at their first value when changed later on.

Simon

signature.asc

Jennifer Hofmeister

unread,
Apr 28, 2015, 5:56:23 AM4/28/15
to jenkins...@googlegroups.com
Hi VJ,
Hi Simon,

Just to sum it up… whatever process runs as a service will only load new env values when restarted. The JNLP and JNLP command line options are spawned from the Jenkins master service, so you’ll want to restart that one after changing your envs so it can pick up new values and pass them on. It’s all about to which Windows service your node goes back to. (ok, you said you already tried this… but just to double-check.)

For me (Windows master and slaves), this was always a safe way to fix env problems, but if you’re concrete sure it’s no service configuration thing and still have troubles, maybe try out the “Environment variables” tickbox in the node configuration. You can have global values overwritten by whatever you specify, and these variables are then passed on to every process in the build.

Best,

Jennifer
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/553E9F81.7010603%40hogyros.de.
For more options, visit https://groups.google.com/d/optout.


From: Varun Jain [mailto:vjai...@gmail.com]
Sent: Montag, 27. April 2015 20:17
To: jenkins...@googlegroups.com
Cc: Jennifer Hofmeister
Subject: Re: Jenkins 1.607 - Environment Variables Stuck

Hi Jennifer,

I've tried it as the service, the JNLP, and the java command line. All of which yielded the same results. I also did try restarting the service.

Thanks,
VJ

On Monday, April 27, 2015 at 5:57:23 AM UTC-7, Jennifer Hofmeister wrote:
Hi Varun,

Does the slave run as a service? If not, it will probably just read the Jenkins service’s old PATH in case that one was not restarted after manipulation.

Simon Richter

unread,
Apr 28, 2015, 11:14:36 AM4/28/15
to jenkins...@googlegroups.com
Hi Jennifer,

> Just to sum it up… whatever process runs as a service will only load
new env values when restarted.

That is expected behaviour, yes.

> The JNLP and JNLP command line options are spawned from the Jenkins
master service, so you’ll want to restart that one after changing your
envs so it can pick up new values and pass them on.

So if the default environment on the slave changes, I need to restart
the slave first for it to pick it up (expected), and then subsequently
restart the master to make it re-fetch the environment from the slave,
which is then written back during execution?

I've had success getting new environment variables accepted by deleting
the node from the master config an recreating them with the same
settings. When the slave then reconnects, the new environment is
accepted (but also sticky).

I think I have also restarted the master at one point and didn't get an
updated environment.

I use a Linux master and Windows slaves BTW.

Simon

signature.asc

Varun Jain

unread,
Apr 28, 2015, 1:17:45 PM4/28/15
to jenkins...@googlegroups.com, jennifer....@younicos.com
Hi Jennifer,

I'll test out the restarting master node in on Thursday and post the results... but I feel that Simon and I are having the same issue here.

Thanks for the quick replies!
VJ

Jennifer Hofmeister

unread,
Apr 29, 2015, 3:54:13 AM4/29/15
to Varun Jain, jenkins...@googlegroups.com

Hi VJ,

 

thanks for the update. Yesterday, I also wrote Simon that my experience is probably not the best to help you, because my system is entirely local. Thus, as I realised yesterday, I’m not actually able to make out a difference between the master host’s env and that of the slaves. Duh! My bad. So I hope that other people in the mailing list can pick up the problem and offer some help.

 

Best,

Jennifer

Henk van Voorthuijsen

unread,
Apr 29, 2015, 7:28:36 AM4/29/15
to jenkins...@googlegroups.com
Varun,

Have you tried setting the variable with SETX instead of SET ?

Henk

Varun Jain

unread,
May 4, 2015, 12:02:34 PM5/4/15
to jenkins...@googlegroups.com
Hi Henk,

Setting the variable within the Jenkins job works properly (both SET and SETX), but the problem is that when we modify the windows variables (a la button clicking on Windows), restart the slave, the master (restarting the Jenkins client/master and/or rebooting), the environment variables modified on the Jenkins Slave (Windows) are not updated within Jenkins. It's like Jenkins, on first run, snapshots the environment variables and never loads them from the OS again.\

Thanks,
VJ

Igor Kostenko

unread,
May 28, 2015, 1:25:29 PM5/28/15
to jenkins...@googlegroups.com
Hello Everyone,

I'm installing new jenkins slave on Windows Server 2008 R2 and have exactly the same issue. Previously we were using Windows 7 as windows slaves (master is on linux) and I never had such issue. And I cannot find old path in windows registry, slave hdd and master directory. Have you found a reason/solution?

Igor

Igor Kostenko

unread,
May 28, 2015, 1:42:25 PM5/28/15
to jenkins...@googlegroups.com
Deleting slave on master and recreating it helped, so environment stored somewhere on master - and not just path - all environment variables. Master is 1.611
Reply all
Reply to author
Forward
0 new messages