Essential steps of Continuous Integration Jenkins to automate android app

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.

 You now configure from where the source should be cloned.

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 

Job Configuration:

* 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:

  1. Sign in to the Google Play developer console as the account owner
  2. Select Settings → API access
  3. Click “Create new project”
  4. Once created, click “Create Service Account”
  5. Follow the link to the Google Developers Console
  6. From the “New credentials” drop-down, choose “Service Account Key”
  7. From the “Service account” drop-down, choose “New service account”
  8. Give the account any name you like, e.g. “Jenkins”
  9. Select “JSON” as the key type (P12 works as well, but JSON is a little simpler)
  10. Click the “Create” button
  11. Note that a .json file is downloaded, named something like “Google Play Android Developer-xxxxxxxxxxxx.p12”
  12. You can now close the page

3.4 Assign permissions to the service account

  1. Return to the Google Play developer console page
  2. Click “Finished” on the dialog
  3. Note that the service account has associated with the Google Play publisher account
  4. Click the “Grant access” button for the account (e.g. “[email protected]”)
  5. Ensure at least the following permissions are enabled:
    • Edit store listing, pricing & distribution
    • Manage Production APKs
    • Manage Alpha & Beta APKs
    • Manage Alpha & Beta users
  6. Click “Add user”
  7. You can now log out of the Google Play publisher account

3.5 Add the service account to Jenkins:

  1. Navigate to your Jenkins instance
  2. Select “Credentials” from the Jenkins sidebar
  3. Choose a credentials domain and click “Add Credentials”
  4. From the “Kind” drop-down, choose “Google Service Account from private key”
  5. Enter a name for the credential — the actual value is not important
  6. Choose the “JSON key” type
  7. Upload the .json file that was downloaded by the Google Developers Console
  8. 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

  1. Create a new free-style software project
  2. Ensure, via whatever build steps you need, that the APK(s) you want to upload will be available in the build’s workspace
  3. Add the “Upload Android APK to Google Play” post-build action
  4. 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
  5. 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
  6. Choose the track to which the APKs should be deployed
  7. 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


Leave a Comment

Scroll to Top