Continuous integration For a Xamarin App with Jenkins and deployments with Hockey App

In the previous post, we saw why Jenkins makes sense for Xamarin build, at least for now. If you have previously worked with continuous integration systems such as Team City, the steps in Jenkins will look familiar to you. The steps follow a logical flow. So, even if you're brand new to this, the learning curve is not that steep.

Jenkins supports a Master/Slave setup. If there is a master running on Windows, perhaps a Mac slave may do the trick. For simplicity, we are going to look at the master running on a Mac.

Jenkins provides a download for Mac and Windows at Jenkins .io. However, I am not going to recommend that. The installer creates a new shared user Jenkins on Mac. This complicates things if Jenkins needs to access anything from the Keychain of the logged in user(likely to be a service account or your own). So, if you are working with TFS Git or any Git repo over HTTPS, you are probably using OSXKeychain Helper or Microsoft's Credential Manager. Jenkins user simply can't access those easily. Creating another user just for Jenkins was not an option for me. We will now see how to get around this issue.

We are going to need Homebrew installed on the Mac. It is a package/application manager for Mac, Mac's Chocolatey from Windows world.
After installation, simply run the commands below:

brew Install Jenkins
brew services start Jenkins

This way Jenkins gets installed for the currently logged in user and the credentials/keychain access problem does not come up.

In order to make Jenkins site available from other machines, follow instructions below:

  • Open homebrew.mxcl.jenkins.plist located in/usr/local/Cellar/Jenkins/2.7 (your installed version could be different)
  • Change the -httpListenAddress= to
  • Fix the url in Jenkins Configuration
  • Restart Jenkins using commands below

    brew services stop jenkins
    brew servics start jenkins

And that's it, you should be able to hit the site installed on the port 8080 if your firewall allows traffic on that port.

Afterwards, I recommend following these very detailed instructions by Jeffry van de Vuurst except for the build script. My modified version of the build script is available on my Github repo.I have updated it to work with the new folder structure Xamarin uses to put the .IPA files in and added a command to restore packages from sources other than the feed.

Xamarin also provides documentation on setting up Jenkins. They recommend downloading the Jenkins app which uses the installer instead of Homebrew, so you may run into issues related to credentials.

There are two ways of triggering the builds Polling and Adding Git hooks. This post goes into the details of both. For simplicity, I use polling with Cron schedule of * * * * *.

Hockey App provides a way of pushing the builds on to the devices. It is fairly cheap and simple to setup. You can create multiple teams and push different builds on to their devices. In Jenkins world, "There is a plugin for that!" is very true. They of course have a plugin for the Hockey App. The setup is very straight forward and the details on setting it up can be found in another post by Jeffry.

At this point, the setup is pretty much all set. It works just fine if you have the provisioning profile downloaded on the build machines using Xcode. While setting all that up in the Apple Developer Portal, it is very important to remember to create the certificate on the build machine otherwise the build fails. It can't create an .IPA file because of the private key issues.

Whenever I ran into issues, I always went to the workspace folder of Jenkins, opened the solution in Xamarin Studio and built it. That revealed a lot of details on the problems that lead to a resolution.

comments powered by Disqus