Post

Setup Jenkins to build iOS .IPA

Jenkins Installation

Step 1:

Install the Java environment before installing Jenkins.

1
2
3
4
work@avadheshs-MacBook-Pro ~ % java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)

If it ain’t installed you would get an error (Unable to locate a Java Runtime).

Download Link for Java: https://www.java.com/en/download/

Step 2:

Download the Jenkins from the official portal.

Link: https://www.jenkins.io/download/lts/macos/

or

Installation Commands:

  • Install the latest LTS version: brew install jenkins-lts
  • Install a specific LTS version: brew install jenkins-lts@YOUR_VERSION
  • Start the Jenkins service: brew services start jenkins-lts
  • Restart the Jenkins service: brew services restart jenkins-lts
  • Update the Jenkins version: brew upgrade jenkins-lts

From the above commands install the latest LTS version and start the service.

After starting the Jenkins service, browse to the location: http://localhost:8080/

Screenshot-2021-01-23-at-6.40.49-PM-1024x605

  • Copy the password from the directory path (/Users/work/.jenkins/secrets/initialAdminPassword)
  • Choose to install the suggested plugins.

Screenshot-2021-01-23-at-6.46.15-PM-1024x605

  • Wait until all the recommended plugins are installed.

Screenshot-2021-01-23-at-6.50.13-PM-1024x605

  • Once all the plugins are installed it’ll automatically be redirected to the user creation page.

Screenshot-2021-01-23-at-8.09.53-PM-1024x610

Click ‘Save and Continue‘ to complete the registration.

Jenkins Configuration

Some plugins could not be loaded due to unsatisfied dependencies.

Screenshot-2021-01-23-at-8.19.31-PM-1024x605

Until the user is created, you can restart Jenkins, Jenkins, and log in with the account you just created or the admin account. Restart the Jenkins method, type in the command line jenkins-lts and press Enter.

Step 1:

iOS packaging requires access to certificates, description files, etc. in the keychain, so we need to install the keychain and description file plugins. Go to Jenkins-> Manage Jenkins-> System Configuration-> Manage Plugins to install related plugins, and you can filter and search through the upper right corner. Then select the plug-in to be installed, check it, and install it. After the installation is successful, you can choose whether to restart Jenkins.

Screenshot-2021-01-23-at-8.31.49-PM-1024x762

Now select ‘Install without Restart’ and wait for the installation to complete, then restart Jenkins.

Screenshot-2021-01-23-at-8.38.09-PM-1024x762

Configure Keychain Plugin

test-Jenkins--1024x897

Add Github Credentials

Credentials are needed to do a git clone. Under Credentials create a new system credential. Here for the demonstration, I’ve used the username and password of my Github account.

Screenshot-2021-01-26-at-2.14.27-PM-1024x605

Setting up a new item

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

  • Assign the project a name
  • Select Git for the source-code management and choose the credential we created earlier(from the drop-down).
  • By default the branch selection would-be master.

Screenshot-2021-01-26-at-2.23.46-PM-1024x605

Screenshot-2021-01-26-at-2.26.42-PM-1024x605

Build steps to create .IPA

  • Select ‘clean build before? to No‘
  • Select ‘generate archive?’
  • Set Xcode Schema File name.
  • Select ‘Pack application, build and sign .ipa?’
    • ${BUILD_DATE} for IPA filename.
    • Output directory to ‘demoBuilds‘.
  • Select ‘Advanced Xcode build options’
    • Set Xcode Project Filename.
    • Set Build Output directory to ‘/Users/work/.jenkins/workspace/JenkinsDemo/DerivedData’.
  • Post Build Steps
    • Add ‘DerivedData/demoBuilds/*.ipa’ for Files to archive. Configuration detail: JenkinsDemo-Config-Jenkins--e1611667357437

Now click on ‘Build Now’ and wait. The result should look like this if it builds without any error. Do check the console output if the build fails.

Screenshot-2021-01-26-at-5.15.19-PM-1024x693

And in the output directory, you would see the IPA file.

Screenshot-2021-01-26-at-5.07.20-PM-768x471

This post is licensed under CC BY 4.0 by the author.