How many times do you need to build your app for DEV, QA, STAGE, PREPROD, PROD, etc. environments?
So much time is wasted on building an .ipa file, uploading it to Crashlytics (HockeyApp, TestFlight, etc.), notifying the QA team about the latest build, etc.
To my mind, to be successful means spending your time on actual work, e.g. writing code. Setting up a continuous integration and delivery process has become critical nowadays, as it helps you to squash out bugs early in the development cycle and saves a lot of developer time.
Ok, blah blah blah. Let’s read some theory about CI/CD.
Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.
There are a lot of tools available that can help you with continuous integration of iOS apps like Fastlane, Xcode Server, Jenkins, Travis and others.
We chose Fastlane + Jenkins.
Continuous Delivery (CD) is a software engineering approach in which teams produce software in short cycles, ensuring that the software can be reliably released at any time. It aims at building, testing, and releasing software faster and more frequently.
Why use Continuous Delivery?
1. Save days of preparing app submissions, uploading screenshots and releasing the app.
2. A colleague on vacation and a critical bugfix need to be released? Don’t rely on one person releasing updates.
3. Increase software quality and reaction time with more frequent and smaller releases.
Let’s automate your builds
Fastlane: Prerequisites
Your ruby version must be 2.4.0 or newer.
- Update ruby
- Install Fastlane
Fastlane: Create Simple Configuration
That is, you can automate your builds just using this command.
- You have successfully added Fastlane using a template.
Jenkins: Add Job
I won’t tell you how to install Jenkins. You can go to the official site for this info.
We start with Job creation.
- Create a job and add the “Execute shell” step to build section.
![fastlane + Jenkins](https://cactus-now.com/wp-content/uploads/2018/02/1_gG77LHzWaezoXDU2SbrEUg-1.png)
Jenkins job. Execute shell step in Build section.
Result
You have the Fastlane template integrated into your project. That can work without any CI tools such as Jenkins, Travis, etc. That only required Fastlane gem and the correct certificates on the build machine.
Also, we integrated Fastlane work like a Jenkins job. It is easier to work with the Jenkins panel instead of a terminal, is it not?
Of course, you can create your Fastlane template using the command “Fastlane init”, then add new steps to your Fastlane lane or Jenkins job. The extended configuration will be explored in a separate series: “Continuous Integration and Delivery processes”.
Remember, spend some hours on automation once and you will be happy for all the coming days/months/years you spend on the project.
This was a small guide about Build automation using Fastlane and Jenkins.