20

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?

Jonik
  • 80,077
  • 70
  • 264
  • 372
mdt
  • 235
  • 1
  • 3
  • 11
  • 1
    I inquired at Google and they answered that this feature is not available for the Play Store. Does anyone have an idea? – mdt Jan 31 '13 at 14:26
  • Quick update if someone is looking for a solution to this. The latest release of the Google Play Developer API allows now to push changes to Google Play listing. See : https://developers.google.com/android-publisher/api-ref/ – Symbiosoft Jul 29 '14 at 13:52

6 Answers6

24

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:
http://android-developers.blogspot.com/2014/07/grow-with-google-play-scaled-publishing.html

Christopher Orr
  • 110,418
  • 27
  • 198
  • 193
twaddington
  • 11,607
  • 5
  • 35
  • 46
  • 1
    This is the good answer now that google has published the API – shalafi Jul 29 '14 at 20:05
  • I have published a Gist based on google's python script to upload an apk without user interaction. Now you can execute this script through Jenkins command shell plugin: https://gist.github.com/marta-rodriguez/20b8684e76fb1262576e – Marta Rodriguez Jul 31 '14 at 12:37
4

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.

Semo
  • 783
  • 2
  • 17
  • 38
  • 1
    oh that sounds painful and really dirt :) How does your thesis like the new developer portal? :) – philipp Mar 20 '13 at 22:26
  • @philipp, sorry, I didn't understand what you mean. How can my thesis like something? Is that an english saying, because as German I am pretty unversed in a lot of english sayings... :-) Is this saying a kind of this one: "How is London like?"? And please which developer portal do you mean? Best regards. – Semo Mar 25 '13 at 11:25
  • Es war als witz gemeint, wie es deiner Arbeit das neue Google Developer Portal gefaellt, da Google gerade alles umgestellt hat. Wenn du einen Scraper geschrieben hast, wird der bald nicht mehr funktionieren. lg – philipp Mar 26 '13 at 05:29
  • @Philipp OK. Got it. In der Arbeit nutzte ich das neue Layout. Momentan geht alles. Ich nutze den Kniff der PageObjects mit relativen Suchmustern, um WebElements zu identifizieren. :) – Semo Mar 26 '13 at 07:05
  • is your script able to upload screenshots in bulk in all the languages and also update descriptions. I would love that, and still upload the APK my self. – philipp Mar 26 '13 at 22:53
  • @philipp Yes it is. And it is no script, but plain Java code. The problem with it, is to get a notification, when the upload process is complete, from the Google Play Developer console. The upload process and control of different languages is done by sequential use of Selenium Tasks. That is why I created 'pathes', the way how you can use the Play Console. I am working to refine that, by using an 'Build'-XML containing the tasks, images, languages and so on. It shall work like maven, when it handles everything to do while a build is made... – Semo Mar 27 '13 at 12:01
  • I would be really interested in that. Can you email me at firstname [at] getkeepsafe.com – philipp Mar 27 '13 at 21:45
  • Just a thought. The console uses AJAX requests to do things. I looked at requests the console's page makes, and noticed all of them are POST requests with JSON objects {"method":...,"params":...,"xsrf":...} and server reply is {"result":...,"xsrf":...}. While it needs more research, I think one can reverse engineer this console's private API and write a wrapper around it. The first thing to do on the way is find out the way authorization works (they use cookies as far as I can see), and then it should be just tedious work to do, no browser emulator with JS involved, just plain HTTP requests. – kstep Jul 05 '13 at 23:41
  • @kstep so true. The cookies and the connection to the JS is well encrypted and obfuscated. Unfortunately I have a lack of time to solve this problem. Do you know a more direct way including a solution? By the way - your suggestion is what I tried first... :-) – Semo Jul 25 '13 at 20:08
3

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

https://wiki.jenkins-ci.org/pages/viewpage.action?pageId=73533143

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)

tostao
  • 2,803
  • 4
  • 38
  • 61
shalafi
  • 3,926
  • 2
  • 23
  • 27
  • I won't try it yet, as there are at least two plugins that claim to do the same. Let's give the developers some time, but it looks promising! – mdt Aug 28 '14 at 13:25
  • haven't seen the other 2. It would be interesting to edit the answer with the different options. – shalafi Sep 01 '14 at 07:17
  • OK, I included the plugins I found above. – mdt Sep 01 '14 at 17:21
2

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.

jetzter
  • 106
  • 4
1

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.

Swan
  • 886
  • 1
  • 9
  • 23
1

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 gserviceaccount.com. 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 https://gist.githubusercontent.com/mix3d/665f4ab329b4482297a2f425ebba402c/raw/0949385dd6c80d0701170746b1bd5fd479303412/basic_upload_apks_service_account.py 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 basic_upload_apks_service_account.py -t beta -p org.example.MyApp -s JSON_file_I_made.json -a MyApp.apk (assuming your JSON file, your APK, and basic_upload_apks_service_account.py 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.

Silas S. Brown
  • 1,469
  • 1
  • 17
  • 18