I am trying to modify PATH in jenkins master node (i have no slaves).From "Global Properties -> Environment Variables" i add 2 entries: "PATH" with value "$PATH:/opt/foo" and "FOO" with value "BAR". Now when i run my free style job with execute shell build step being "echo $PATH; echo $FOO" i see that PATH was not modified whereby FOO is displayed correctly. Why is that? Is there any way to modify PATH from jenkins global configuration ? I managed to modify PATH on a job level via EnvInject plugin but what i am really looking for is to modify PATH for all jobs.
5 Answers
You are doing it right. The same Manage Jenkins => Global Properties => Environment variables works for me.
Please note that if you have the EnvInject plugin installed, it seems to mask the environment variables from Jenkins global configuration. So uninstall EnvInject and try again.

- 11,047
- 1
- 27
- 27
-
3I do have it EnvInject plugin installed so you maybe right that it can interfere with env properties global jenkins setting. I will give it a try on Monday. – user62058 May 10 '14 at 07:39
-
2Thank you very much you I spent 4 hours trying to figure out what's wrong! It was EnvInject plugin. – snowindy Sep 23 '14 at 13:09
-
you should also pay attention to the node properties, click on your build node, then `configure` and check what's define in `Environment variables` – fduff Apr 23 '15 at 08:03
-
2
-
For me, setting an environment variable in Jenkins at /configure works BUT watch out for these: 1) /systemInfo will show the old PATH, 2) the job itself will show `PATH = $PATH:/new/path` & will not be expanded, even though it is during runtime, 3) `echo $PATH` in the freestyle job will show the wrong path. Lastly, if it isn't working try prepending instead of appending, e.g. /new/path:$PATH. I do have EnvInject plugin installed. – Elijah Lynn Apr 19 '18 at 22:57
-
In my case i use PATH+EXTRA for the variable name. and it work – Mohammad Ravanbakhsh Jun 10 '23 at 12:01
Jenkins also supports the format PATH+<name>
to prepend to any variable, not only PATH:
This is also supported in the pipeline step withEnv
:
node {
withEnv(['PATH+JAVA=/path/to/java/bin']) {
...
}
}
Just take note, it prepends to the variable. If it must be appended you need to do what the other answers show.
See the pipeline steps document here.
You may also use the syntax PATH+WHATEVER=/something to prepend /something to $PATH
Or the java docs on EnvVars here.

- 3,738
- 1
- 22
- 38
Running Jenkins 2.150.1 on Mac OS X installed with homebrew. I couldn't get the PATH
environment to change by updating the PATH
environment variable as described in some of the other answers here and on similar questions. In the end I updated the Jenkins installation's plist. I added the following to /usr/local/Cellar/jenkins-lts/2.150.1/homebrew.mxcl.jenkins-lts.plist
:
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>
And then restarted the service:
brew services restart jenkins-lts

- 6,035
- 4
- 38
- 45
-
Great and worked for me. Feel like the other PATH mods are really not as good as this for Brew OSX. – Dan Devine May 23 '19 at 01:19
I was facing the same problem as my wsimport command was not being picked up by Jenkins master. This comes with Java, so I waned to append JAVA_HOME/bin to the PATH variable in jenkins master.
Environment name should be Path and not PATH. Please see attached image for the same, where I have ammeneded JAVA_HOME/bin to PATH variable

- 3,317
- 34
- 31
-
1This approach applies only for the Freestyle projects. If you work with declarative pipeline follow instructions here: https://stackoverflow.com/questions/43987005/jenkins-does-not-recognize-command-sh – Patrick Mar 06 '19 at 16:59
When appending to PATH variable through Jenkins (Manage Jenkins => Global Properties => Environment variables), use "Path", not "PATH" for the variable name.

- 10,903
- 8
- 60
- 70