800-862-5965 sales@macminivault.com

Jenkins is a 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 will 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.

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 install java11
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/11/manifests/11.0.12
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/11/blobs/sha256:339415a
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Pouring openjdk@11--11.0.12.catalina.bottle.tar.gz
==> Caveats
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk

openjdk@11 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have openjdk@11 first in your PATH, run:
echo 'export PATH="/usr/local/opt/openjdk@11/bin:$PATH"' >> ~/.profile

For compilers to find openjdk@11 you may need to set:
export CPPFLAGS="-I/usr/local/opt/openjdk@11/include"

==> Summary
🍺 /usr/local/Cellar/openjdk@11/11.0.12: 679 files, 298.1MB

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 https://ghcr.io/v2/homebrew/core/jenkins-lts/manifests/2.303.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/jenkins-lts/blobs/sha256:315a29
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Pouring jenkins-lts--2.303.1.all.bottle.tar.gz
==> Caveats
Note: When using launchctl the port will be 8080.

To start jenkins-lts:
brew services start jenkins-lts
Or, if you don't want/need a background service you can just run:
/usr/local/opt/openjdk@11/bin/java -Dmail.smtp.starttls.enable=true -jar /usr/local/opt/jenkins-lts/libexec/jenkins.war --httpListenAddress=127.0.0.1 --httpPort=8080
==> Summary
🍺 /usr/local/Cellar/jenkins-lts/2.303.1: 8 files, 72.3MB

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: Enumerating objects: 1428, done.
remote: Counting objects: 100% (307/307), done.
remote: Compressing objects: 100% (221/221), done.
remote: Total 1428 (delta 119), reused 240 (delta 80), pack-reused 1121
Receiving objects: 100% (1428/1428), 421.95 KiB | 6.21 MiB/s, done.
Resolving deltas: 100% (595/595), done.
Tapped 1 command (35 files, 521.5KB).
==> 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, 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.

Update 2021-Sept-14: Article has been updated to use Java 11 instead of Java 8, which is now supported by Jenkins.