Did you know that you can navigate the posts by swiping left and right?

Continuos Integration with Jenkins to build iOS .IPA

07 Mar 2017 . category: devops . Comments
#sysadmin #jenkins #ci #IOS #ipa

In this post, I’ll show you how Jenkins can be used to automate continuos integration for IOS application to build IOS .ipa.
Requirements

  • Xcode
  • Jenkins
  • MacOS

From my structure, I am using one Jenkins master installed on another Linux server and use Jenkins slave on MacOS. After configuring Jenkins master and slave, We add the following plugins to Jenkins master. (Jenkins slave will use the recommended plugins).

  • Git
  • Xcode Integration
  • Hookeyapp (Used to manage version of .Ipa)
  • Slack (Used to notify event)

Setup a new Jenkins item
Create a new Jenkins project using freestyle option and the following settings.

  • Give your project name
  • Select Git, paste the right repository and select the right credentials.
  • Make sure the right branche is selected Jenkins IOS
  • Additional, add Job weight number to define the number of processor(s) used to build. Add the lable of MacOS slave used to build IOS application at Retrict where this project can be run.

Jenkins IOS

  • If we want to schedule strigger, select build periodically.

  • To build IOS .ipa, we need three build steps:

  1. Excute shell for running pod install or independent packages

cd ${WORKSPACE}
/usr/local/bin/pod install
  1. Xcode build
  • To use xcode, we should know more about team provisioning profiles

Jenkins IOS

Link ref: Link

  • If everything is fine until this point, you can go on and add an Xcode build step. This plugin will invoke the xcodebuild command line tool and you can add all the build parameters here.
  • In this case:
  • Target: yourProjectName
  • Clean before build? Yes
  • Generate Archive? Yes
  • Pack application and build .ipa? Yes
  • .ipa file name pattern: ${VERSION}
  • Output directory: ${BUILD_NUMBER}/${BUILD_ID}
  • Unlock keychain? Yes
  • Keychain path: ${HOME}/Library/Keychains/login.keychain
  • Keychain password: your administrator user password
  • Xcode Schema File: yourProjectSchema
  • Custom xcodebuild arguments: -sdk iphoneos -archivePath yourPath
  • Xcode Workspace File: ${WORKSPACE}/yourProjectName
  • Xcode Project Directory: ${WORKSPACE}
  • Xcode Project File: ${WORKSPACE}/yourProjectName
  • Build output directory: ${WORKSPACE}/DerivedData
  • Provide version number and run avgtool? YES
  • Technical version: ${BUILD_ID}

Jenkins IOS

  1. Export IOS .ipa
    • Create file options.plist with following content

Jenkins IOS

  • Excute shell to export IOS .ipa

cd ${WORKSPACE}/build
xcodebuild -exportArchive -archivePath  YourXcarchive  -exportPath  YourPath  -exportOptionsPlist  options.plist
  • After building the IOS .ipa, we can upload to hockeyApp or send to the FTP server then QA can use for testing. We also can use slack plugin to notify the event for the job.

Jenkins IOS


Me

Harry Nguyen is an awesome person. Abosolutely true!.