Continuous integration is a process in which all development work is integrated as early as possible. The resulting artifacts are automatically created and tested. This process should identify errors as very early in the process. Here we will discuss Continuous Integration Jenkins to automate android app for Test fairy and Play store.
Jenkins is one open source tool to perform continuous integration and build automation. The basic functionality of Jenkins is to execute a predefined list of steps. The trigger for this execution can be time or event based. For example, every 20 minutes or after a new commit in a Git repository.
The list of steps can, for example, include:
- perform a software build with Apache Maven or Gradle
- Run a shell script
- Archive the build result
- Afterward, start the integration tests
Jenkins also monitors the execution of the steps and allows to stop the process if one of the steps fails. Jenkins can also send out notification about the build success or failure.
Jenkins can be extended by additional plug-ins, e.g., for building and testing Android applications or to support the Git version control system.
Continuous Integration Jenkins android for Test fairy and Play store
Step 1: Creating build jobs for Android applications
To create an Android build job on Jenkins, select New Job, and enter a job name. Select theBuild a free-style software project option.
Configure you desired build trigger. In the above screenshot, the job would check the Git repository every 15 mins.
Add a Gradle build step to your Jenkins jobs.
That is it, you should be able to run your Android build.
Step 2: Setup for Testfairy
Select TestFairy iOS/Android Uploader from Add post-build action menu
* The API Key can be found in your account settings
The resulted TestFairy links will be listed in the console output
Step 3: Setup for Play store
3.1 Google Play publisher account
For the initial setup only, you must have access to the Google account which owns the Google Play publisher account.
This is required to enable API access from Jenkins to your Google Play account.
Note that having admin access is not enough; you need the account owner.
You can see who the account owner is under Settings → User accounts & rights in the Google Play developer console.
3.2 Install plugin
Install this plugin via the Jenkins plugin manager.
Or if installing the plugin via other means, ensure that the prerequisite Google OAuth Plugin, Token Macro Plugin and their dependencies are also installed.
3.3 Create Google service account
To enable automated access to your Google Play account, you must create a service account:
- Sign in to the Google Play developer console as the account owner
- Select Settings → API access
- Click “Create new project”
- Once created, click “Create Service Account”
- Follow the link to the Google Developers Console
- From the “New credentials” drop-down, choose “Service Account Key”
- From the “Service account” drop-down, choose “New service account”
- Give the account any name you like, e.g. “Jenkins”
- Select “JSON” as the key type (P12 works as well, but JSON is a little simpler)
- Click the “Create” button
- Note that a .json file is downloaded, named something like “Google Play Android Developer-xxxxxxxxxxxx.p12”
- You can now close the page
3.4 Assign permissions to the service account
- Return to the Google Play developer console page
- Click “Finished” on the dialog
- Note that the service account has associated with the Google Play publisher account
- Click the “Grant access” button for the account (e.g. “[email protected]”)
- Ensure at least the following permissions are enabled:
- Edit store listing, pricing & distribution
- Manage Production APKs
- Manage Alpha & Beta APKs
- Manage Alpha & Beta users
- Click “Add user”
- You can now log out of the Google Play publisher account
3.5 Add the service account to Jenkins:
- Navigate to your Jenkins instance
- Select “Credentials” from the Jenkins sidebar
- Choose a credentials domain and click “Add Credentials”
- From the “Kind” drop-down, choose “Google Service Account from private key”
- Enter a name for the credential — the actual value is not important
- Choose the “JSON key” type
- Upload the .json file that was downloaded by the Google Developers Console
- Click “OK” to create the credential
Jenkins now has the required credentials and permissions in order to publish to Google Play.
Once you’ve set up a job (see the next section) and confirmed that uploading works, either delete the downloaded JSON file or ensure that it’s stored somewhere secure.
3.6 Freestyle job configuration
- Create a new free-style software project
- Ensure, via whatever build steps you need, that the APK(s) you want to upload will be available in the build’s workspace
- Add the “Upload Android APK to Google Play” post-build action
- Select the credential name from the drop-down list
- The credential must belong to the Google Play account which owns the app to be uploaded
- Enter paths and/or wildcards pointing to the APK or APKs to be uploaded
- This can be an Ant-style **/*-release.apk pattern, or a comma-separated list of filenames, relative to the root of the workspace
- Choose the track to which the APKs should be deployed
- If you’re deploying a production release, you can choose a rollout percentage
- Optionally choose “Add language” to associate release notes with the uploaded APK(s)
- You add entries for as many or as few of your supported language as you wish, but each language must already have been added to your app, under the “Store Listing” section in the Google Play Developer Console.
Press Save to finish the job definition. Press Build Now on the job page to validate the job works as expected.
After a while, the job should go to green or blue (depending on your configuration), if successful. Click on the job and afterward on Console Output to see the log file. Here you can analyze build errors.
In simple words when a developer is lazy and did not want to do a lot of work they implement continuous integration Jenkins. So as they push their code on some version control system like Git, bitbucket etc Continuous Integration Jenkins (CI) server automatically run all the unit tests and if tests success CI generate a build which you can send to testers. If you are lazier you can add more scripts, so build automatically send to all of your QA’s or testers and if you are super lazy there is a possibility you can implement Continuous Deployment (CD). In CD you can publish your apps on the app store by doing only one push in a branch. So if you are super lazy as a developer then implement continuous integration Jenkins or CD and enjoy more time in sleeping or in anything like you. So if you want to implement Continuous Integration Jenkins then these steps will help to automatically run your android apps.
- Jenkins: Documentation for Jenkins server set up.
For further reading
- How to integrate Authorize.Net with Magento android App?
- Twilio voice: Receive call on your Android mobile.