I’ve been reading a lot of articles about using Jenkins Continuous integration recently, so I’ve had a bit of a go. Here’s how I used Jenkins Continuous Integration for my iOS project.

Related blog

Using shell commands

Package iOS projects and upload them to third-party testing platforms (fir. Im, Dandelion and other platforms) by shell using xcodeBuild and xcrun commands of Xcode.

Related blog
  • Xcodebuild official documentation
  • Xcrun official documentation
  • Shell tutorial
  • Shell package to FIR/dandelion

Jenkins’ understanding of continuous integration

Set up Jenkins on your MAC, install the corresponding plug-in, associate the code repository (git, SVN) in the project configuration, you can set a fixed time to check the repository or a fixed time cycle check the repository to check your code repository, if the repository changes, then execute the compilation and other operations. Each compilation first updates the repository code locally and then compiles locally, so you can use all of the native commands.

If your iOS project uses Cocoapods, it is recommended that you submit your code with the Pods folder, podfile. lock file, and XXX.xcworkspace file ‘. The diagram below:

The reason for doing this is that the code from POD is already stored in a third-party warehouse, so there is no need to drag it to my own warehouse to occupy space. After setting this, we need to add Execute Shell operation in Jenkins’ build step. Enter the script pod install –verbose –no-repo-update. The diagram below:

The hole I stepped in

Toss this thing really did not little step on the pit, here to share, to the pit of the students to provide a solution.

Keychains and Provisioning Profiles Management

IOS packaging requires signature files and certificates, so we’re using Keychains and Provisioning Profiles Management, but you’ll notice that in the blog post I provided above, In Keychains and Provisioning Profiles Management, Filename and UUID are available at the bottom of the Provisioning Settings.

Not in your Settings, as shown below:

Keychains: Keychains: login. Keychains: Keychains: login. Keychains: Keychains: login. Keychains But you click on the image in the choice of the top file button, you will find that you want to choose the login. The keychain files under this path (/ Users/Jiar/Library/Keychains), you can not choose, An easy way to do this is to copy login.keychain to your desktop and upload the file.

Enter Jenkins’ global Settings as shown below:

After setting the signature file and certificate path, you can reference this path in the project, as shown in the figure below. The Code signing & OS X keychain options TAB in Xcode is Unlock keychain? To configure the path)

In the above steps, we have set the path of the signature file and certificate, and also uploaded the login.keychain file, through which we can select the certificate corresponding to the signature file for the project. It also sets the path of the Unlock Keychain in Xcode (the actual path is set in system Settings, this is just a reference) and enters the Unlock password (which is your MAC login password). Now that we’re done, we need to tell the project to select the signature file so that we can find the corresponding certificate through the signature file. We checked Keychains and Code Signing Identities in the construction environment of the project, and then performed the following operations, as shown in the figure below:

Upload it to the third-party test platform

The third party test platform here is fir. Im and Dandelion

Uploaded to fir. Im

Sudo gem install fir-cli –no-ri –no-rdoc sudo gem install FIR -cli –no-ri –no-rdoc You can use this tool to upload your app to fir. Im in two ways.

  • Use the plugins provided by Fir. im for Jenkins. The tutorial is here
  • To upload the file, run the following command:fir p ${WORKSPACE}/build/TestJenkins.ipa -T #API Token#
Upload to dandelion

Here is an official DANDelion API, check this out

Email notification

Firstly, it should be known that Jenkins came with an email Notification, but could not customize the appearance of the email content, and then they used a third-party plug-in Extended email Notification.

Firstly, enter the system Settings and find the email notification. I use email 163 here. The server information of netease 163 free email is shown as follows:

We will find that with SMTP service, if SSL is enabled, there are two ports to choose from: 465 or 994. If this protocol is not used, port 25 is used.

My Settings are shown below:

Note that the password here cannot use your email login password, the reason is that email 163 requires authorization code to log in to the third party. Meanwhile, we use SMTP service, we also need to go to the email to set well, otherwise it will fail. POP3/SMTP/IMAP and the client authorization password are set separately in the following two pictures.

Once all of this is set up, there is no problem. Click on email notification to test the configuration by sending test email and fill in a mailbox to test whether it is successful.

If it’s successful, you can get rid of email notifications, because we don’t use Jenkins’ own email notification service. “Why do you want us to do that? Are you kidding us?” Don’t worry, here we mainly use Jenkins’ own email Notification service to test the email. If this is successful, we can configure this content into the third-party plug-in Extended Email Notification. Ok, next look at Extended E-mail Notification. Similarly, find Extended E-mail Notification in Jenkins’ system Settings. Since Extended E-mail Notification is very long, I divided the picture to show:

The Jenkins Advanced Series 01 replaces Jenkins’ default email notification with email-ext. Of course, you can look at the instructions that come with Extended E-mail Notification, find it in system Settings, scroll to the bottom of Extended E-mail Notification, Find the Content Token Reference option and click on its question mark icon at the far right to expand the Content. As shown below:

After setting the default values in system Settings, open project Settings and add Editable Email Notification in post-build operations. The configuration is shown in the figure below:

A Failure – Any)

A Success

Now that you’ve configured how to use the mail service in Jenkins, here’s another point. Our mail service uses the Extended E-mail Notification plug-in instead of Jenkins’ own mailbox service, which means don’t add E-mail Notification operations to post-build operations.

conclusion

That’s my experience with the Jenkins Continuous Integration iOS project, thanks to the bloggers I mentioned in this post. If you find any errors or inappropriacies while reading this article, please do so in the comments. If you have any questions, please feel free to post them in the comments.

Welcome to follow my personal wechat subscription number, I will share the development of dry goods from time to time.