android – How to upload an APK from Jenkins/Hudson to Play Store?-ThrowExceptions

Exception or error:

I implemented a continuous integration pipeline using Jenkins, but as final step I want Jenkins to deploy/upload the signed APK file to Google Play Store and AndroidPit. I looked for Jenkins/Hudson plugins but only found two: one for Appaloosa and one for Zubhium.

I have a working developer account both on Google Play and on AndroidPit and can manually upload the APK that Jenkins produces. But my question is: Does anybody know a way to teach Jenkins (e.g. via a shell script?) to upload the APK to the mentioned app stores?

How to solve:

There is a Google Play Android Publisher plugin for Jenkins which uses the Google Play Publishing API, announced at Google I/O 2014.

Google has also released Java and Python libraries to help make use of the API.

For more info on the API, see also:


I can talk only for Google’s Play Store. There is a way, but be warned, it isn’t beautiful, you have to code your solution. I am right now writing a Bachelor Thesis to solve this problem – “Continuous Delivery for Android Applications”. My solution is mine, this means I don’t raise a claim to have the perfect solution, but I can say it is quite working prototype.

I found out the following:

  • The first Solution is none. Google offers an Play Store API, but it lacks to upload stuff. Seems that they were already thinking about to make such an API, but it only offers In-App billing control

  • The 2nd solution is to use Apache HttpComponents Library, which lets you implement your own Client for the Google Play Developer Console, but HttpClient lacks a JavaScript Interpreter… Several ways to implement or add one. But of course, not the easiest way.

  • The 3rd Solution I am working on, is to use Selenium Web Browser Automation Framework. So basically I create PageObjects from those Play Store Pages and dialogues. After that you can create some Factory to maintain “pathes” of controlling these PageObjects.

Using them you have two options as far as I can see, for instance the WebDriver Objects which uses an “invisible” browser process like FF or Chrome and another I use is ChromeDriver which uses a visible Browser process, to perform the User actions. And don’t forget to have Exception Handlers, which scans the Webpage for appearing errors, while in use.

There are a lot of pitfalls, due to possible changes in the Design from Google, which lets your Software break. But there are also some ways to handle that. =) And create an XML containing all valueable information about an app, which comes in handy, when continueing to the next step.

You can create a Maven Plugin. This you can load into your Continuous Integration Server. I hope I could help you a bit.


Since Google Play released the upload API, a plugin has been made:

I haven’t tried it yet, but looks like it’s exactly what we were looking for.

There are other plugins that claim to do the same (thanks @mdt)


I believe it is not included in the PlayStore API currently to reduce stress on the system and to avoid abuse.

I believe we may see this in the gradle plugin and in the IDE in the future.
While we wait for google decide to open up the API, here is a solution, that is so sill, that i just had to propose it:

If you have a GUI, use GUI automation for the last step.


Google Play Android Publisher plugin for Jenkins is a good one. However, it doesn’t support uploading descriptions and screenshots (at least for now).

I found decent Gradle plugin, called Gradle Play Publisher. It supports uploading apk, updating Metadata, and uploading screenshots. And it only needs a few steps to setup.


First go to Google Play Console in a browser, open the page for your app, and look for the option to allow a new email address to upload APKs. If it’s not there, it probably means you are not the administrator of that Play Store account and you need to ask the person who is the administrator to add it for you (on a per-app basis). To find out what email address to add, go to Google Developer Service Accounts and create a JSON key for any of your existing Google developer service accounts, or create a new service account with a JSON key. Note the email address associated with the service account for which you have created (or will create) the JSON key. It will most likely be something at This is the email address that must be given permission to upload APKs by someone who has admin access to your Play account.

After that has been done, download Madison Dickson’s updated version of Marta Rodriguez’s script via wget and install dependencies via pip install google-api-python-client (or sudo pip install google-api-python-client as appropriate).

Then in the automated script you can use (for example) python -t beta -p org.example.MyApp -s JSON_file_I_made.json -a MyApp.apk (assuming your JSON file, your APK, and are all in the current directory and the pip install has been done on that machine or container).

I strongly recommend uploading to beta (hence -t beta in the above) rather than directly to production. Just in case something breaks and it somehow gets as far as the APK upload. I think the final press of “rollout to production” should always be done by a human. But if you really want to do that automatically as well, you can use -t production instead.

Leave a Reply

Your email address will not be published. Required fields are marked *