Installing Jenkins OS X Homebrew
Homebrew is the easiest way to install and manage applications on OS X. Let's go through how weinstall and configure Jenkins.
Installation
Follow the instructions at http://brew.sh/ if you have not had Homebrew installed. Then, let's proceed to install Jenkins
$ brew update && brew install jenkins
Jenkins is a Java web application. Download and install the latest Java Runtime Environment manually, or use Homebrew Cask to install it
$ brew cask install java
Starting Jenkins
After Jenkins is installed successfully, follow the instructions to start Jenkins on login
$ ln -sfv /usr/local/opt/jenkins/*.plist ~/Library/LaunchAgents
If you want to configure Jenkins to launch on system startup, for all users on OS X, then copy the plist file to the system Launchd location instead
$ sudo cp -fv /usr/local/opt/jenkins/*.plist /Library/LaunchDaemons
$ sudo chown `whoami` /Library/LaunchDaemons/homebrew.mxcl.jenkins.plist
You can always start Jenkins manually with
$ /usr/local/bin/jenkins
or if you have set up your PATH correctly when installing Homebrew, simply
$ jenkins
Restarting Jenkins
If you have an older version of Jenkins and you are upgrading it, then you can restart it this way:
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
Jenkins Options
The default Jenkins startup command in ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist is very simple.
<string>/usr/bin/java</string>
<string>-Dmail.smtp.starttls.enable=true</string>
<string>-jar</string>
<string>/usr/local/opt/jenkins/libexec/jenkins.war</string>
<string>--httpListenAddress=127.0.0.1</string>
<string>--httpPort=8080</string>
Launchd starts a java command, listening on only the loopback network interface and using the port 8080 and listen to SMTP connection over TLS.
Network Port
8080 is a common network port for web development. Tomcat defaults to
8080. On my machine, I run Gitbucket on 8080. Let's change it to "8181"
<string>--httpPort=8080</string>
Java Options
If you have any additional Java runtime options, add them to the configuration file. For example, we want to set:
- Initial and maximum VM size to 1G
- Use CMS garbage collector for more responsive system
- Garbage collect PermGen classes - more details here
- Limit PermGen size
<string>-Xms1G</string>
<string>-Xmx1G</string>
<string>-XX:+UseConcMarkSweepGC</string>
<string>-XX:+CMSClassUnloadingEnabled</string>
<string>-XX:MaxPermSize=256m</string>
More information for Hotspot Java VM options.
Jenkins Plugins
A fresh Jenkins installation is ready to be used, especially if you only need to manage Java projects. There are many Jenkins plugins that can make Jenkins much more powerful. To access Plugin Manager, go to Jenkins ⇒ Dashboard ⇒ Plugin Manager or the url http://jenkins:8181/pluginManager/available.The easiest way to install a plugin is to view the list of all published plugins in the Plugin Manager, click and Install and restart Jenkins. To install a plugin manually, copy the plugin-name.hpi file to Jenkin's directory. In the Homebrew installation, that will be $HOME/.jenkins/plugins. Restart Jenkins and the plugin will be installed.
These are the plugins I have installed:
Jenkins configuration
Besides the launchd configuration file explained above, all other Jenkins configuration is stored in $HOME/.jenkins. The main configuration file is config.xml. You really should not edit the configuration files by hand. Use the Jenkins web interface to make changes http://jenkins:8181/manage
Upgrading Jenkins
As a continuous integration server, Jenkins itself is frequently updated. You can check if a new version of Jenkins is available
$ brew update && brew outdated jenkins
Upgrading jenkins is as easy as
$ brew upgrade jenkins
Homebrew's default behaviour is to keep older versions. If you don't
need the older versions of Jenkins anymore, you can remove them
$ brew cleanup jenkins
Preserve Configuration And Plugins
You don't want to set up Jenkins all over again on every upgrade. The
good news is, Jenkins server files and your configuration are in
separate locations. Your new Jenkins installation will automatically
pick up your existing configurations and plugins at "$HOME/.jenkins"