Continuous Integration in iOS using JENKINS

AKANSHA DIXIT
Mar 23, 2017 · 5 min read

JENKINS is an open source automation server, which can be used to automate all sorts of tasks such as building, testing, and deploying software. It allows Continuous Integration. Continuous Integration is a development practice that requires developers to integrate code into a shared repository at regular intervals. Jenkins will be installed on your server or on your local system. Details about Installation and configuration is given below:

Installation and Configurations:

To do basic setup of Jenkins,automate iOS builds, trigger emails on failure and stability of builds, to get downloadable ipa follow the following steps:

Step 1: Download JENKINS for MAC.

Step 2: Open Jenkins. Enter details(username and password).

Step 3: Click on Manage Jenkins → Manage Plugin → Search for plugins and install→ Restart jenkins → Cross check installed plugins.

Note: Install Subversion Plugin for svn, Xcode integration to give settings related to xcode.

Step 4: Back to Jenkins Homepage.Click on New Item, Enter Job name,select freestyle project .Click OK.The job is created now.

Step 5: Click on your job,Click on configure.

Step 6:We will do now Project level Configuration,which includes following Steps:

In General,give project name.

In Source Code Management section,select Git or Subversion(according to your need, i used svn) → give repository url → Enter credentials of svn.

In Build Triggers, select Poll SCM to give time interval we want jenkins to check for commit changes and trigger build.(For Ex: to give 15 mins time we will use H/15 * * * *).

In Add Build Step, select XCODE → give name of the target for which you want to create build. In Configuration give the mode Debug or Release as required by your project.

To create .ipa click settings in General build settings select Pack application and build .ipa? → give .ipa filename pattern (it is the name you want to give to your ipa).

Again Click on Add Build Step → Execute shell → write command to execute your script.

Note: The script file (.sh) should be saved in workspace of our jenkins (${JENKINS_HOME}/workspace).

In Post-build Actions ,select Archive the artifacts to get downloadable ipa.These files (builds) are downloadable files and will be accessible from jenkins home webpage.

Note: To avoid errors related to provisioning profile and certificate :

  1. Copy the provision profile to Jenkins user folder. The provision profile is under in the folder /YourUserName/Library/MobileDevice/Provisioning Profiles,

For Example: In my machine, the provision profile files are under /Users/username/Library/MobileDevice/Provisioning Profiles. In the mac, the Jenkins will be in /Users/Shared/Jenkins, create the following folder: /Users/Shared/Jenkins/Library/MobileDevice/Provisioning Profile, then copy the .mobileprovision file to this folder.

2. Copy your iPhone developer certificate from “login” keychain to “System” keychain.

Detailed steps: Open the “Keychain Access” application, click the login tab, right click the certificate like “iPhone Developer: your_name (XXXXXXX)”, choose copy, then click the “System” tab, right click mouse, choose “Paste 2 items”; you might need to do the same thing with the certificate like “iPhone Distribution: your_name”.

Step 7: Email Configuration:

Go to Jenkins home page → Manage Jenkins → Manage Plugins → Install 3 plugins:

  1. Email Extension Plugin
  2. Email Extension Template Plugin
  3. Extreme Notification Plugin

We need to do some global level configuration to through email notifications.Here SMTP (Simple Mail Transfer Protocol) server is required.

So, Go to Jenkins → Manage Jenkins → Configure System.

Check on Use SSL so that the mails can be triggered to any domain(gmail.com,yahoo.com etc) By clicking on Test configuration, we can test this configuration whether it’s properly configured or not.

We can also override this setting at project level, to do so,follow following steps:

Click on Post-build Actions,In Email Notification section enter email id in Recipients,Check on Send email for every unstable build option.

Click on Post-build Actions,In Editable Email Notification section,enter email id in in project recipient list.

Click on advanced settings → Add trigger → Always.

Step 8: Click Apply → Save → Build Now → Console Output.

In console output you may see build fails or succeeds. If fails then reason can be viewed in console output,on success you will get all the details and path of your .ipa.

Hope this will help you folks who are trying to integrate JENKINS in iOS for Continuous Integration