Setup a Mac Slave for Jenkins

Casey Garland
Apr 2, 2015 · 3 min read

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 com.jenkins.ci.plist and add the following.

Replace http://192.168.1.151:8080 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" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> &ltplist version="1.0"> &ltdict> &ltkey>Label&lt/key> &ltstring>com.jenkins.ci&lt/string> &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>http://192.168.1.151:8080/computer/mac_vm/slave-agent.jnlp&lt/string> &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 com.jenkins.ci.plist sudo chmod 644 com.jenkins.ci.plist

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


Originally published at www.parsed.io.

    Casey Garland

    Written by

    i like to build all things web and mobile

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade