Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

iOS CI with Jenkins

Co-Authored by Alex Kramer.

It often happens that you join a project once it has been going for a few weeks and miss out on all the fun things at the beginning. Thus, we find ourselves having never set up CI for iOS and thus this blog post is born.

Our goal was to keep this short, simple and to the point, but providing enough detail so you are not left hanging with lots of questions.

Lets get to it.

CI Machine

1. Figure out what machine you want to use as your CI machine.
2. Check for Apple updates and make sure Xcode is the latest release.
3. Install the Xcode Command Line Tools

Download Jenkins

1. Head over to Jenkins and download the Mac OS X native package (on the right hand side of the site)
2. Install Jenkins
3. Upon installation completion, Jenkins will open your browser and point it at your local instance (localhost:8080) of Jenkins

Setting up the Jenkins User

1. Make the Jenkins user an Admin:

sudo dseditgroup -o edit -a jenkins -t user admin

2. Add Jenkins to the developer group:

sudo dscl . append /Groups/_developer GroupMembership jenkins

3. Setup the Jenkins user to automatically login upon booting the machine:

System Preferences > Users & Groups > Login Options > Automatic Login > set to Jenkins > restart CI machine // you should now be logged in as Jenkins 

4. Move Jenkins from a LaunchDaemon to a LaunchAgent. This will allow Jenkins to launch windowed processes like the simulator.

sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci
mv /Library/LaunchDaemons/org.jenkins-ci /Library/LaunchAgents/
sudo launchctl load /Library/LaunchAgents/org.jenkins-ci

Jenkins Plugins

1. Click Manage Jenkins on the left sidebar and select Manage Plugins
2. Click the Available tab and filter by git in the Filter: search box
3. Check the box next to the Git Plugin and click Download now and Install after restart
4. Check Restart Jenkins when installation is complete

Setting up the CI task

1. Now back to Jenkins (localhost:8080). Click on New Item in the left nav
2. Enter your Project Name for Item Name
3. Select Build a free-style software project
4. click OK
5. Enter your project info (name, description)
6. Under Source Code Management select Git
7. Where it says Repository URL enter in your Github repository info like so: (make sure your CI machine has access to your Github repository)
8. Under Credentials click Add and select SSH Username with private key. Under Private Key select From a file on Jenkins master and enter the path to your private key (should be located in /Users/Shared/Jenkins/.ssh)
9.Under Build Triggers select Build when a change is pushed to GitHub or any other trigger you would like to have that runs your app
10. Under Build / Execute Shell / Command put whatever rake task you want called when your CI runs. We usually like to create a special rake task just for this purpose so that we can make sure all of our dependencies are up to date (like pods, etc).
11. Click Save
12. You should now be able to click build now and your CI task should run

Hope this helps if you ever find yourself needing to setup CI for iOS.

Happy Coding.

  1. Brian Kelly says:

    Woo! Lots of good Jenkins/OS X tips in here that aren’t iOS specific that are super useful. This will definitely help the next time we need to set up Jenkins on a Mac.

  2. Glauco says:

    Hi guys! Great post! I have just a few questions:

    Before step 3 don’t we have to (re)define a password for the Jenkins user?
    In the step 4 aren’t we talking about org.jenkins-ci.plist instead of org.jenkins-ci?
    The command ‘mv /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchAgents/’ also needs sudo, right?

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *