Reputation: 3605
I'm facing this weird problem , struggling to solve since almost couple of days.
Working: On mac mini command prompt , I switch to jenkins user and can run docker command without any problem.
Not Working: but when I run a jenkins job , inside shell command step docker is not recognized.
I'm getting error
docker: command not found
docker --version
But mentioning explicit path of docker , does work
/Users/buildserver/Library/Group\ Containers/group.com.docker/bin/docker --version
Question : Why docker command can't look into correct path ?
Permissions
lrwxr-xr-x 1 buildserver staff 71 Oct 14 10:44 docker -> /Users/buildserver/Library/Group Containers/group.com.docker/bin/docker
jenkins uses is part of staff group.
Thanks in advance.
Regards, Vikram
Upvotes: 22
Views: 19762
Reputation: 41
I have solved the above issue by updating the file
/usr/local/Cellar/jenkins-lts/2.176.3/homebrew.mxcl.jenkins-lts.plist.
I have added the path of docker in the above file.
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Docker.app/Contents/Resources/bin/:/Users/admin/Library/Group\ Containers/group.com.docker</string>
</dict>
Upvotes: 4
Reputation: 1928
For others (Late but worthy), I installed Jenkins via Brew, so I add Docker's path to the file below: /usr/local/Cellar/jenkins-lts/2.176.3/homebrew.mxcl.jenkins-lts.plist (Whole file looks like below)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.jenkins-lts</string>
<key>ProgramArguments</key>
<array>
<string>/usr/libexec/java_home</string>
<string>-v</string>
<string>1.8</string>
<string>--exec</string>
<string>java</string>
<string>-Dmail.smtp.starttls.enable=true</string>
<string>-jar</string>
<string>/usr/local/opt/jenkins-lts/libexec/jenkins.war</string>
<string>--httpListenAddress=127.0.0.1</string>
<string>--httpPort=8080</string>
</array>
<key>RunAtLoad</key>
<true />
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Docker.app/Contents/Resources/bin/:/Users/Kh0a/Library/Group\ Containers/group.com.docker/Applications/Docker.app/Contents/Resources/bin</string>
</dict>
</dict>
</plist>
Then restart Jenkins' service:
brew services restart jenkins-lts
Upvotes: 48
Reputation: 19144
The PATH
which Jenkins jobs start with isn't the same as the path which the Jenkins user sees in bash. In the Jenkins UI you can edit the environment varables (from Manage Jenkins/Configure System), and add the Docker folder to PATH
:
PATH -> $PATH:/Users/buildserver/Library/Group\ Containers/group.com.docker/bin/
Some more detail in the answer to this question.
Upvotes: 5