There is nothing special in how Jenkins gets the value of the PATH environment variable: It inherits PATH from its parent process. What the parent process is and why it sets PATH to the value you see, depends on how you start Jenkins.
If you have used one of the "native installers" available at jenkins-ci.org, you probably have a script /etc/init.d/jenkins, which starts it on system startup and studying that script will give you the answer. (I just guessed from the directory names below that you are using some version of Linux. If you are using some other Unix variant, please let us know and we can give you better help.) When you ssh into the jenkins account, your PATH gets installed according to the rules layed out in the man page of the login shell of jenkins account. If the shell is bash, run the command "man bash" and search for section title "INVOCATION". The same rules apply for the PATH seen by the slave process and the details depend on how the slave process is started, automatically by Jenkins by running the command "ssh hostname java -jar slave.jar" or some other way for JNLP slaves. The reason why you see different value for PATH depending if you run something on the slave or log in on the slave is due to the way shell on the remote host is invoked. On any Unix system, when you ssh in like this: "ssh hostname", you will get an interactive login shell. And when you run a command on the remote system without logging in, like this: "ssh hostname command", the remote system will invoke a non-interactive non-login shell to execute the command. Check the man page of the shell on how the invocations differ in these cases. To make long story short, the easiest way to control the value of PATH environment variable is to set it to the value you want in Manage Jenkins -> Configure System -> Environment variables. This sets the environment variables for build steps running on master. Each slave configuration can set environment variables for build steps running on that slave. If this way is not suitable, you need to understand what I wrote above and study the Jenkins init script and relevant shell man pages. -- Sami 2012/4/7 Thomas Sondergaard <t...@medical-insight.com>: > When I execute a job containing the followin shell script > > echo PATH=$PATH > > on master and on a slave I get different outcomes. > > == Job executed on master: == > PATH=/sbin:/usr/sbin:/bin:/usr/bin > > PATH when logging in with ssh as jenkins user: > /usr/lib64/ccache:/usr/local/bin:/bin:/usr/bin:/usr/sbin:/sbin:/var/lib/jenkins/bin > > == Job executed on slave: == > > PATH=/usr/kerberos/bin:/usr/lib64/ccache/bin:/usr/local/bin:/bin:/usr/bin > > Path when logged in as jenkins user: > /usr/kerberos/bin:/usr/lib64/ccache/bin:/usr/local/bin:/bin:/usr/bin:/home/jenkins/bin > > > In neither case are the PATHs from the ssh shell and the jenkins job the > same, but on master it is particularly reduced. I want /usr/lib64/ccache/bin > to be in the PATH on master, and I would like to understand how jenkins gets > the value it uses for PATH. > > I have EnvInject plugin installed and I'm running jenkins 1.458. > > Thanks, > > Thomas >