Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jenkins on Mac, PATH is not set right, no /usr/local/bin

I recently installed Jenkins, using Homebrew. I also installed Mercurial using Homebrew.

I can successfully clone an hg repo just fine - from Terminal. But if I try and do the same thing as part of a job in Jenkins, it fails.

So, in by job, I told Jenkins to run a shell script echo $PATH. Sure enough, the path /usr/local/bin is not there. If I execute the same command from Terminal, it's there.

So, what is the best way to modify PATH so that Jenkins is pulling the same PATH that I'm using, when I echo it from Terminal?

Note, Jenkins is running from the same user account that I'm logged into doing these tests, so I can't fathom why this is happening.

like image 627
Dan Morrow Avatar asked Mar 25 '13 16:03

Dan Morrow


People also ask

Where is Jenkins PATH Mac?

Browse to http://localhost:8080 (or whichever port you configured for Jenkins when installing it) and wait until the Unlock Jenkins page appears. From the Jenkins console log output, copy the automatically-generated alphanumeric password (between the 2 sets of asterisks).

How do I set Environment PATH in Mac?

For a new path to be added to PATH environment variable in MacOS just create a new file under /etc/paths. d directory and add write path to be set in the file. Restart the terminal. You can check with echo $PATH at the prompt to confirm if the path was added to the environment variable.

How can you modify PATH variable in Jenkins master?

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.


2 Answers

In your launchd .plist file for Jenkins, you can set the PATH environment variable by using the following:

<key>EnvironmentVariables</key> <dict>     <key>PATH</key>     <string>(insert your path value here)</string> </dict> 

That should set the PATH to whatever you need.

like image 194
gaige Avatar answered Oct 05 '22 14:10

gaige


For some reason, Jenkins doesn't keep /usr/local/bin in the PATH when connecting to a slave.
You can add it to the PATH either by

  • Adding an environment variable on the Node Configuration, or

  • Adding a .bashrc file on the user folder with

     PATH="/usr/local/bin:${PATH}" 

Note: The Mac client must be disconnected and then reconnected via the Jenkins web app after editing ~/.bashrc

like image 45
Maxime Viargues Avatar answered Oct 05 '22 15:10

Maxime Viargues