CI/CD for IOS using Jenkins (Build an .ipa using Jenkins)

CI/CD of IOS apps using JENKINS

Jenkins is the Continuous Integration and Continuous Deployment tool used by many organizations. The most important factor of Jenkins is the build automation. Like for mobile application development you can build, test and deploy your app to the relevant app store automatically, And you could also set the build execution in a way that if any developer commits the code Jenkins will build -> test -> deploy the app(ideally you should put the condition on deployment like if all the test cases being executed successfully then only deploy).

In this post, I will describe, how you can make the ipa file using Jenkins.

Installation of Jenkins with XCode plugin:

1) Download and Install Jenkins with default plugins

2) Move to the Jenkins(http://localhost:8080) and Select: Manage Jenkins

3) Click on: Manage Plugins

4) Click on the Available tab and search the Xcode and install it

Configure Jenkins Job:

1) Move to Dashboard and click on New Item from the left side.

2) Give any name and select Freestyle Project.

3) Now this is the most important step you need to follow. In this step, you need to provide all the information about your code repository, build process commands(Here it won’t since we are using Xcode plugin), select the configuration and set the paths.

  • Here I am using Git so I need to mention the repository URL by selecting git option. If your repository is private than you do need to set the credentials as well(see this for more info.)
  • Move to Build and click on Add build step button and select the Xcode option, it will add the Xcode related fields.
  • In General build settings click on the Settings button and fill the following fields accurately.

I) Select Pack application, build and sign .ipa? option.

II) Configuration: The export method of the .app to generate the .ipa file. Should be one in ‘development’, ‘ad-hoc’, ‘enterprise’ or ‘app-store'.

III) .ipa filename pattern: A pattern for the ipa file name. You may use ${VERSION} and ${BUILD_DATE} (yyyy.MM.dd) in this string.

  • Now before moving to Code signing & OS X keychain options section you need to create Development team from Jenkins Global configuration, to do that follow below.

I) Move to Jenkins Dashboard > Manage Jenkins > Configure System

II) Move to Xcode builder section and click on Add button which is in front Apple Development Teams field, it will give you two fields so fill VALID Team Name and Development Team ID

III) Add Keychain and fill out VALID values for Keychain Name and Keychain password(Keychain path would already be there)

IV) Apply and Save

Ideally you should first only get the git repo, don’t use any XCode or build. After getting the git repo from Jenkins you can move to the workspace directory(/Users/Shared/Jenkins/Home/workspace) and open the XCode workspace file.

Move to General tab on Xcode and verify that Provisioning profile and other info are correct. Now try to build that project it should be successfull. It it fails then first correct the provsioning profile errors.

MAKE SURE AUTOMATICALLY MANAGE SIGNING IS NOT SELECTED

You can get the Team Name and Bundle Identifier from this page:

You can get your Team Id from https://developer.apple.com/account/#/membership

And for keychain info you can move to Keychain Access utility and find out the working valid cerificates under System and Login.

  • Let’s get back to the Jenkins job configuration part, Move to Build > Code signing & OS X keychain options and follow below steps:

I) Select Manual signing?

II) Select the Development Team which you have recently added on Jenkins Global Configuration.

III) Under Provisioning Profiles fill the valid Bundle ID(From XCode) and Provisioning profile UUID(You can find it from your provisioning profile .mobileprovision file)

IV) Select Unlock Keychain?

V) Select the recently created Keychain value from drop down.

  • At last move to Advanced Xcode build options section and fill Xcode Schema File: <Project Name>, Xcode Workspace File fields:<Project Name> and Xcode Project Directory: $WORKSPACE
  • Apply and Save
  • Below is the screenshot of the whole page:

4) After saving the build configuration you can run the build :)

I do hope you have a BLUE BUILD at first trial…. : D

Please let me know your concerns, opinions, and questions if you have any. !

Thank you,

Pratik

QA Automation Engineer