Notes: This article is the 3rd part of the “GitLab CI/CD - Android” series. It is direct follow up to Part-1 & 2 , so I highly recommend you read that first before starting.
As a developer, our main aim is to automate almost every process from testing to deploying. This article series is all about the concept & setup of CI(Continuous Integration) & CD(Continuous Deployment) for Android.
Setup Google PlayStore Service Account
- First, Open the Google Play Console
- Select the Settings tab
- Expand the Developer account option
- Select the API access option. Please be aware that this page could take a few minutes to load.
- Click Create Service Account. This will open a pop-up.
- Click Google API Console in the pop-up. This will open a new tab in your browser.
- Click Create service account. This will open a pop-up. Set the Service account name as you wish, Select Role: Owner, and select KeyType: JSON
- Click Create. A file named “Google Play Android Developer-XXXXXXXXXX.json” will start to download. Save this JSON file. Depending on your browser settings, the file may start to download automatically or ask you for permission to start the download.
- Close the pop-up. You’ll see the new service account created. You can close this tab now.
- Switch back to the pop-up you left open at step 5. Now click Done.
- Under the section Service Accounts → Permissions, click Grant access.
- You’ll be redirected to the Users & Permissions page. The new service account should now be listed here.
- Do NOT edit the Email field. - Keep Access expiry date selected on Never - Choose Administrator from the Role dropdown - Leave all GLOBAL permissions checked - Click Add user to close the dialogue
This is how we set up a service account for Google PlayStore. Now copy that service email id and get back to Android Studio for the play store release setup
Open app/build.gradle file and add the following block to it.
here we set tracks for our release build like ‘production’, ‘alpha’, ‘beta’ etc. now paste your service account email id that you copy from the developer console. The last and very important option is the jsonFile that allows GitLab to authenticate and upload build directly from Container, so copy the line as it is like file(‘/PlayJson/play-store-key.json’) and paste it into your project. We will dynamically create that file from GitLab CI/CD Variable via .gitlab-ci.yml file.
Setup GitLab CI/CD Variable
- Open Gitlab.com and select the project that you want to set up a CI/CD Variable.
- Select Settings > CI/CD option
- After that, the following screen will open that asks for the Input variable key and Input variable value. Now open that JSON file that we downloaded while setting up the Google Play Service account. Select and Copy all the content of that file and paste it into the input variable value. now we need an Identifier for this value to set the Input variable key like PLAY_STORE_JSON and click on Save variables to save the value.
Note: remember this key for future reference. We will use it in our .gitlab-ci.yml file.
here we completed the Service account setup and GitLab CI/CD Variable.
Now we just remain to set up .gitlab-ci.yml file that we will see in the next part. Stay tuned!!!
Everyone loves what you guys are up too. This
sort of clever work and exposure! Keep up the excellent works guys I’ve
incorporated you guys to my personal blogroll.
Oh my goodness! Incredible article dude! Thank you so
much, However I am encountering troubles with your RSS. I don’t know why I am unable
to subscribe to it. Is there anybody else getting
identical RSS issues? Anybody who knows the answer will you kindly respond?
Thanx!!
Hey there! I know this is kind of off topic but I was
wondering which blog platform are you using for this
site? I’m getting tired of WordPress because I’ve had
issues with hackers and I’m looking at options for another platform.
I would be fantastic if you could point me in the direction of a good platform.
Inspiring story there. What happened after? Thanks!
Simply want to say your article is as astonishing.
The clearness to your submit is just nice and that i can think you are a professional in this subject.
Fine along with your permission allow me to clutch your RSS feed to stay up to date with imminent post.
Thanks a million and please continue the gratifying work.
Hey there! I’ve been reading your website for some time now
and finally got the courage to go ahead and give you a shout out from Dallas Texas!
Just wanted to mention keep up the excellent work!
No matter if some one searches for his vital thing,
so he/she wants to be available that in detail, so that thing
is maintained over here.