Setup a Mac Slave for Jenkins

Jenkins is the most prominent solution for on-site continuous integration. It can run on most platforms, including OSX. Since it can run on a mac, you can use it to setup a continuous integration strategy for iOS apps. Chances are you will not want your core Jenkins instance running on a Mac, luckily Jenkins lets you set up slaves to run tasks.

Add Slave in Jenkins

First you need to add the slave to Jenkins.

Manage Jenkins -> Manage Nodes -> New Node

Give it a name and select dumb slave

Click Ok

Enter /Users/jenkins/build/ for remote root directory Click Save

Basic Mac Setup

Create a user named jenkins

Go into Jenkins -> Manage Jenkins -> Manage Nodes Click on the node you just created

Click Launch to connect to Jenkins as a slave

You might have to install Java, there will be a pop up if you do.

Thats it, no you can use OSX for Jenkins builds.

Run Jenkins Slave as a Service

Our goal is to have OSX connect as a Jenkins when it starts and to stay connected.

Install Java Development Kit

You will need this to connect to Jenkins from the command line.

I used the version found here but you might want to google and see what the latest is.

Create plist

This is the most complicated step in the process. Create a new file called and add the following.

Replace with the address of your Jenkins machine. Note that this example does not use authentication for Jenkins. If your setup uses authentication (it most likely does) you will need to add additional argument to the plist.

&lt?xml version="1.0" encoding="UTF-8"?> &lt!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" ""> &ltplist version="1.0"> &ltdict> &ltkey>Label&lt/key> &ltstring>> &ltkey>UserName&lt/key> &ltstring>jenkins&lt/string> &ltkey>SessionCreate&lt/key> &lttrue/> &ltkey>ProgramArguments&lt/key> &ltarray> &ltstring>java&lt/string> &ltstring>-Djava.awt.headless=true&lt/string> &ltstring>-jar&lt/string> &ltstring>/Users/jenkins/Desktop/slave.jar&lt/string> &ltstring>-jnlpUrl&lt/string> &ltstring>> &lt/array> &ltkey>KeepAlive&lt/key> &lttrue/> &ltkey>StandardOutPath&lt/key> &ltstring>/Users/jenkins/Desktop/stdout.log&lt/string> &ltkey>StandardErrorPath&lt/key> &ltstring>/Users/jenkins/Desktop/error.log&lt/string> &lt/dict> &lt/plist>

Move to LaunchDaemons

Move this file to /Library/LaunchDaemons You will be prompted for authentication

Change file permissions

Now you need to change the file permissions so that it will be handled correctly by root.

sudo chown root sudo chmod 644

Thats it. Now your OSX machine will connect to Jenkins as a slave whenever it is on.

Copyright © 2020.