800-862-5965 sales@macminivault.com

Jenkins is Continuous Integration automation control software that allows developers to automate repetitive parts of the software development process. While Jenkins can be installed on many operating systems, this guide will focus on the macOS install process.

This guide assumes you have a fresh install of the latest macOS along with Xcode, and that you don’t already have a Jenkins master server. In a future guide, we will add Jenkins slave servers to the setup.

There are a few ways to install Jenkins on macOS – we’re going to install it using a package manager for macOS called Homebrew. If Homebrew is already installed then skip the next step (check by running “brew -v” in Terminal).

Let’s install Homebrew by opening Terminal and entering the following command (this command is all one line):

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

The installer will give you a list of things it’s going to do, just press enter and Homebrew will be installed.

Now that you have Homebrew installed, you can type check to see if there are any recommendations for your setup:

brew doctor
Your system is ready to brew.

For example, you may have an outdated version of Xcode, in which case you may want to upgrade that:

$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: Your Xcode (8.0) is outdated.
Please update to Xcode 9.4 (or delete it).
Xcode can be updated from the App Store.

Before installing Jenkins, we need to install a specific version of Java required by Jenkins – it may ask you for your password to set permissions properly:

$ brew cask install java8
==> Tapping homebrew/cask
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'...
remote: Counting objects: 4132, done.
remote: Compressing objects: 100% (4121/4121), done.
remote: Total 4132 (delta 27), reused 601 (delta 8), pack-reused 0
Receiving objects: 100% (4132/4132), 1.30 MiB | 10.54 MiB/s, done.
Resolving deltas: 100% (27/27), done.
Tapped 1 command and 4034 casks (4,141 files, 4.1MB).
==> Caveats
This Cask makes minor modifications to the JRE to prevent issues with
packaged applications, as discussed here:

  https://bugs.eclipse.org/bugs/show_bug.cgi?id=411361

If your Java application still asks for JRE installation, you might need
to reboot or logout/login.

Installing java8 means you have AGREED to the license at
  https://www.oracle.com/technetwork/java/javase/terms/license/index.html

==> Satisfying dependencies
==> Downloading http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442f
==> Downloading from https://edelivery.oracle.com/otn-pub/java/jdk/8u181-b13/96a
######################################################################## 100.0%
==> Verifying checksum for Cask java8
==> Installing Cask java8
==> Creating Caskroom at /usr/local/Caskroom
==> We'll set permissions properly so we won't need sudo in the future.
Password:
==> Running installer for java8; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are i
installer: Package name is JDK 8 Update 181
installer: Installing at base path /
installer: The install was successful.
🍺  java8 was successfully installed!

Now we can install Jenkins – we’re going to install the LTS (long-term support version, which is typically more stable):

$ brew install jenkins-lts
==> Downloading http://mirrors.jenkins.io/war-stable/2.121.3/jenkins.war
==> Downloading from http://ftp-chi.osuosl.org/pub/jenkins/war-stable/2.121.3/je
######################################################################## 100.0%
==> jar xvf jenkins.war
==> Caveats
Note: When using launchctl the port will be 8080.

To have launchd start jenkins-lts now and restart at login:
  brew services start jenkins-lts
Or, if you don't want/need a background service you can just run:
  jenkins-lts
==> Summary
🍺  /usr/local/Cellar/jenkins-lts/2.121.3: 7 files, 74.5MB, built in 18 seconds

We want the Jenkins web interface to be accessible from anywhere (not just on the local machine), so we’re going to open up the config file:

sudo nano /usr/local/opt/jenkins-lts/homebrew.mxcl.jenkins-lts.plist

Find this line:

<string>--httpListenAddress=127.0.0.1</string>

And change it to:

<string>--httpListenAddress=0.0.0.0</string>

(to exit out of nano after making the change, hit Ctrl+X, hit Y to save the changes, and hit Enter)

Let’s start Jenkins and set it to run automatically when the system is rebooted:

$ brew services start jenkins-lts
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Counting objects: 14, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 14 (delta 0), reused 7 (delta 0), pack-reused 0
Unpacking objects: 100% (14/14), done.
Tapped 1 command (43 files, 55.2KB).
==> Successfully started `jenkins-lts` (label: homebrew.mxcl.jenkins-lts)

The rest of the configuration will mostly be done in a browser on the local machine. Open up Safari and visit http://localhost:8080 , where we will see a screen like this:

Grab the red highlighted text and in Terminal use the ‘cat’ command to display the initial password:

$ cat /Users/administrator/.jenkins/secrets/initialAdminPassword
fff69c0883fb4cdb9aa85bbd72dd2fd8

Copy that password and paste it into the Unlock Jenkins page. We’re done with Terminal, feel free to close it.

We can now Customize Jenkins and install some plugins. For now we’re going to choose Install suggested plugins.

The installer now downloads and installs the plugins:

Create an admin user and Save and Continue:

Set the URL that users will be using to log in to Jenkins. If users will be connecting to the server remotely, it’s best to set up an A record (like jenkins.yourdomain.com) and set the Jenkins URL to http://jenkins.yourdomain.com:8080. Click Save and Finish:

Setup is complete – click Start using Jenkins.

The rest of the configuration will be done within the Jenkins web interface. You can now create jobs, manage Jenkins and install new plugins, and add new users.

How to Start / Restart Jenkins on macOS

To start Jenkins and make sure it runs after a reboot:

brew services start jenkins-lts

To restart the Jenkins service and make sure it runs after a reboot:

brew services restart jenkins-lts

Note: If you didn’t install the LTS version of Jenkins, don’t include the “-lts” portion of the above commands.