docker: command not found ( mac mini ) only happens in jenkins shell step but work from command prompt
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
More question
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.