Automating Publishing to the Play Store
The Google Play Developer API allows you to push app updates to the Play Store automatically. This ability allows you to trigger builds on your continuous integration server (i.e. Jenkins) and have them uploaded to the Play Store for testing tracks (internal, alpha, beta), as well as pushing to production directly. Note that since August 2021 new apps are required to publish with the Android App Bundle (AAB) on Google Play instead of an APK.
This guide will show you how you can setup publishing builds directly through the command-line, or how you configure a continuous integrations server such as Jenkins to do the same. Regardless of which approach, you will need to setup Google API access.
Setup for Google API access
Note: The screenshots below show an older version of the consoles. In the current flow, documented in the Play Developer API getting-started guide, you create the service account in the Google Cloud Console (with the Google Play Android Developer API enabled for that Cloud project), download a JSON key rather than a
.p12key, and then invite the service account’s email address on the Play Console’s Users and permissions page to grant it publishing access. Current tooling such as the Gradle Play Publisher plugin expects a JSON key.
- Inside the Google Play Store for your project, navigate to
Settings->API Access:

- There should be a
Service Accountssection where you need to click theCreate Service Account button. Click on the link shown on the first step to visit the Google Developers Console.

- Click on the
Create New Client IDbutton.

- Click to create new
Service Account. Make sure to also request the.p12 Key Fileinstead of JSON:

-
You will be prompted to download the
.p12file. Save it somewhere. -
Note the service account email associated with this new account. You should see it appear in the Google Developer Console:

- Once you are done, go back to the Google Play Developer Console and navigate to the
Settings->API Access. Make sure the checkboxes forEdit store listing, pricing & distribution,Manage Production APKs, andManage Alpha & Beta APKsare checked for the Google Service account used. (If you intend to upload an alpha or beta SDK through a Google service account, apparently these permissions must be checked according to this discussion.

Setting Up Gradle Plugin (for command-line publishing)
If you want to push your builds directly through Gradle, you can install the Gradle Play Publisher plugin (currently in maintenance mode: issues are ignored, but pull requests are accepted). Note that the first version of your app must be uploaded manually through the Play Console — the plugin can only handle subsequent uploads.
- Apply the plugin in your
app/build.gradle.ktsfile using theplugins { }block:
plugins {
id("com.android.application")
id("com.github.triplet.play") version "4.1.1"
}
- Configure the plugin with the JSON key of the Google service account created during the API access setup by adding a
playblock alongside theandroidone:
play {
serviceAccountCredentials.set(file("your-key.json"))
track.set("internal") // or "alpha", "beta", "production"; defaults to "internal"
}
Avoid committing the unencrypted key to source control: you can instead put the JSON file’s contents in the ANDROID_PUBLISHER_CREDENTIALS environment variable and omit the serviceAccountCredentials property.
- The plugin creates the following tasks for you:
| Command | Description |
|---|---|
| publishBundle | Uploads the App Bundle for every variant. |
| publishApk | Uploads the APK (and splits, if available) for every variant. |
| publishListing | Uploads the descriptions and images for the Play Store listing. |
| promoteArtifact | Promotes an existing release to another track. |
| bootstrapListing | Fetch data from the Play Store & bootstrap the required files/folders |
Task names follow the Android Gradle Plugin naming convention, so per-variant tasks such as publishReleaseBundle are also generated. You can now type gradle commands such as the following:
./gradlew publishBundle
Setting Up Jenkins (for automating CI builds)
This section mainly shows how to setup the Google Play Android Publisher plugin with Jenkins. You can most likely adapt the same steps for other services that enable beta distribution, such as Firebase App Distribution. (Older versions of this guide pointed at HockeyApp, which Microsoft folded into Visual Studio App Center in November 2019; App Center was itself retired on March 31, 2025.)
-
Make sure you have already gone through the process of Building Gradle Projects with Jenkins CI and already have a Jenkins job correctly running. You will only need to install a Jenkins plugin that will allow you to create a build step that will enable the APK generated to be published to the Google Play store directly.
-
Verify that you’ve the followed the guide about how to configure Google API access.
-
Inside Jenkins, go to
Manage Jenkins->Manage Plugins. Assuming the plugin has not yet been installed, select theAvailabletab and search for theGoogle Play Android Publisher Plugin. -
Navigate to the
Credentialssection in Jenkins and load the service account key file downloaded during the initial setup process of setting up Google API access (the plugin recommends the JSON key type, though.p12keys also work). A basic walkthrough video also demonstrates how to do this step.

- Add a post-build step to your existing Jenkins project.

a. Make sure to choose the credential name from the drop-down list. It should belong to the Google Play account that manages the app.
b. Enter path and/or an [Ant-style](http://stackoverflow.com/questions/69835/how-do-i-use-nant-ant-naming-patterns) wildcard pattern for the APK. For instance, the example in the screenshot expects the APK to be generated inside `**/build/outputs/apk/yourappname*.apk`.
c. Choose what track to which the APKs should be deployed (Alpha, Beta, Production).
d. You can create release notes before you start the build. If you forget to do this step or your automated process pushes the build, you can edit them later directly on the Google Play Developer Console.
GitHub / Jenkins integration
Do not follow these steps if you intend for your Jenkins jobs to push directly to Production tracks. You should always verify your builds before rolling out to production users.
-
Jenkins jobs can be triggered via remote API commands by sending an HTTP POST to the job’s
buildendpoint, authenticated with your Jenkins username and an API token (created from your personalSecurityconfiguration page) over HTTP Basic authentication:curl -X POST -L --user your-user-name:apiToken \ https://ci.mycompany.com/job/AndroidBuild/buildAvoid the legacy per-job
Authentication tokenbuild trigger shown in older screenshots — putting a credential in the URL’s query string leaks it into proxy and access logs.

- Go to your GitHub repository
Settingspage and visit theWebhooks & Servicessection. Enter thePayload URLfor your Jenkins build job.

- You can also control which GitHub events should fire these Jenkins build jobs:
