Running Jenkins on OSX as a different user
Running Jenkins as a different user can be achieved in two ways as shown below. Either by installing Jenkins.app (preferred) or installing Jenkins by source. I prefer option 1 because it is straight-forward and uses the current OSX user by default. This means your .ssh
keys is recognized.
Option 1: Use Jenkins.app
-
Install from https://github.com/stisti/jenkins-app
-
Run Jenkins.app
- It will ask for settings
- By default, jenkins.app install the ff:
~% cd ~ ~% ls -la .jenkins total 40 drwxr-xr-x 13 rupert staff 442 10 Sep 13:05 ./ drwxr-xr-x+ 113 rupert staff 3842 10 Sep 13:06 ../ -rw-r--r-- 1 rupert staff 159 10 Sep 13:05 hudson.model.UpdateCenter.xml -rw------- 1 rupert staff 1675 10 Sep 13:00 identity.key drwxr-xr-x 2 rupert staff 68 10 Sep 13:00 jobs/ -rw-r--r-- 1 rupert staff 907 10 Sep 13:05 nodeMonitors.xml drwxr-xr-x 28 rupert staff 952 10 Sep 13:00 plugins/ -rw-r--r-- 1 rupert staff 46 10 Sep 13:04 queue.xml.bak -rw-r--r-- 1 rupert staff 64 10 Sep 13:00 secret.key -rw-r--r-- 1 rupert staff 0 10 Sep 13:00 secret.key.not-so-secret drwxr-xr-x 5 rupert staff 170 10 Sep 13:05 updates/ drwxr-xr-x 3 rupert staff 102 10 Sep 13:00 userContent/ drwxr-xr-x 24 rupert staff 816 10 Sep 13:00 war/ |
- To stop, simply quit Jenkins.app
Option 2: Jenkins on OSX by source
- Install jenkins from http://jenkins-ci.org/. Choose Mac OS X or this direct link http://mirrors.jenkins-ci.org/osx/latest
- Jenkins will run as user “jenkins” by default. To see the files installed, read
vim /Library/Application Support/Jenkins/Uninstall.command
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist sudo rm /Library/LaunchDaemons/org.jenkins-ci.plist sudo rm -rf /Applications/Jenkins "/Library/Application Support/Jenkins" /Library/Documentation/Jenkins sudo rm -rf /Users/Shared/Jenkins sudo rm -rf /var/log/jenkins sudo dscl . -delete /Users/jenkins sudo dscl . -delete /Groups/jenkins pkgutil --pkgs | grep 'org\.jenkins-ci\.' | xargs -n 1 sudo pkgutil --forget |
Run Jenkins as a different user
- To run jenkins as a different user on OSX, say rupert.
sudo vim /Library/LaunchDaemons/org.jenkins-ci.plist> |
<key>GroupName</key> <string>wheel</string> … <key>UserName</key> <string>rupert</string> |
- Reload Jenkins
sudo launchctl unload -w /Library/LaunchDaemons/org.jenkins-ci.plist sudo launchctl load -w /Library/LaunchDaemons/org.jenkins-ci.plist |
References:
– how to run jenkins as a different user
– Launchctl:Dubious permissions on file: Problem Installing Jenkins