Continuous Integration / Continuous Delivery (CI/CD) pipeline is a fantastic way to make your app development process efficient. It reduces risks, improves build quality, speeds-up build releases, decreases manual efforts, and even makes rollbacks easier.
The pipeline contains varied sets of tools and frameworks to support development, QA, and operations teams in delivering the desired apps at a fraction of the cost and time to the end users.
An Overview of Key Technologies
In order to create effective pipeline-enabled automation, several key technologies need to be put into place. Here is a brief overview of technologies we have seen work wonders for our clients.
Why Should You Implement a CI/CD Pipeline for Your App?
Implementing an automated build pipeline is not a trivial process. However, many positive benefits accrue once you implement this automation, giving you a substantial ROI.
The most significant reason for implementing the CI/CD-enabled pipeline is the staggering amount of time you will save on the build process. In our experience, the time to complete the build process dropped from two (or more) days to just a few hours!
Another key benefit derived from our solution is a vast reduction in procurement costs. No matter how many new devices you add to the device support policy, Sauce Labs can handle it.
The automated build system we discuss here allows you to define an environment dynamically. This means you don’t have to worry about creating a duplicate build for each environment.
Pipeline Creation for Mobile Applications
Let's take a look at some details on pipeline creation. We start with the iOS environment and follow that with Android.
1. iOS CI/CD Pipeline
The iOS build process shares similarities to that used for Android. However, due to Apple’s unique requirements, there are substantial differences. Image 2 shows the iOS CI/CD pipeline process.
2. Android CI/CD Pipeline
There are multiple steps required to fulfill the build process requirements. The steps are illustrated in Image 3.
Sauce Labs Integration with CI/CD Pipeline
We integrate Sauce Labs with the CI/CD pipeline using the steps below.
STEP 1
STEP 2
Use the curl command with security options to upload the appropriate files to Sauce Labs as recommended by Sauce Support.
As per the mobile devices license in Sauce labs, add the device names in the choice parameters of Jenkins jobs.
Build environments are controlled at the Jenkins level. All keys and configuration are maintained in a separate secured Bitbucket repository. The environment selection of the Jenkins job ensures that the appropriate configuration files and keys are inserted into the codebase from this separate repository using the Jenkins “Active Choice Parameter” plugin.
STEP 3
The automation suites are based on the Maven build tool and can be triggered via Maven build commands. Here is an example:
# mvn clean install
You determine the selection of the mobile devices using the parameters mentioned in Step 2. The build file will be named after the environment, date, and build number. The selection of a build file is dynamic based on the Jenkins job.
STEP 4
Once the “Sauce OnDemand” plugin is installed in Jenkins, it records the logs of test suites in Sauce labs. Use the HTML publisher plugin in Jenkins, post them in the Jenkins job at each build level.
STEP 5
The same HTML file will be sent to respective DLs via email as an attachment from Jenkins using the Email Extension Plugin.
Key Obfuscation
An essential part of CI/CD pipeline automation is the ability to obscure sensitive access keys and other credentials. Upload the API keys and property files to a separate secured repository. This technique works best if you create a set of branches representing each of the environments you plan to use (e.g., testing, staging, production).
We use a Jenkins pipeline to perform key obfuscation via the Active Choice Reactive Parameter plugin. The syntax is shown in Image 11:
Image 12 shows the branches that are automatically selected based on the above choices.
Single Build Dynamic Environment Selection
The ability to dynamically select the environment saves you from having to create duplicate builds. Instead, you can enable dynamic environment selection by executing the build file and build flavors representing respective environment values.
The build flavors are embedded in the code by developers. During the build process, we inject the environment tag into the build command definition so it will generate the desired build.
ANDROID
iOS
Conclusion
The process of certifying a mobile app that you develop is tedious and time-consuming. Without the proper automation tools, the pace at which you deploy new releases slows to a crawl. The result is that app consumers become frustrated, and you lose business.
In this blog, we showcased how three key technology components, version control, a CI/CD pipeline, and Sauce Labs, are employed to automate the build certification process.