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/
- Copy the password from the directory path (/Users/work/.jenkins/secrets/initialAdminPassword)
- Choose to install the suggested plugins.
- Wait until all the recommended plugins are installed.
- Once all the plugins are installed it’ll automatically be redirected to the user creation page.
Click ‘Save and Continue‘ to complete the registration.
Jenkins Configuration
Some plugins could not be loaded due to unsatisfied dependencies.
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.
iOS Related Plugins Installation
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.
Now select ‘Install without Restart’ and wait for the installation to complete, then restart Jenkins.
Configure Keychain Plugin
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.
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.
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
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.
And in the output directory, you would see the IPA file.