How to automate Android build process on Bitrise CI (part 1)
There are lots of companies that offer CI services such as Travis CI, Circle CI, Bitrise and etc. I don’t want to focus on the comparison because is not the aim of this story. I have worked with all of these three services and found Bitrise super convenient and flexible. I automated my Debug/Release build system based on Bitrise CI and I’m going to explain how you can send Android version code/name via curl to Release workflow in order to create a Release build.
Since you might not familiar with Bitrise I explain a bit about how to import your project from Github to Bitrise and configure it in this part. In the next part we will jump deeper into Workflow page and explain how to write an script in order to catch Android version code/name variables from curl, pass these variables to a Gradle Task we will make, create a Release build based on and finally push changes to repo if Release build had been successful.
Import repo to Bitrise
- Everything starts by creating an account on Bitrise. So create one and login to you account.
- Import your repository to Bitrise. Go to your dashboard and click on Add New App button. Choose your repository and import your project. Follow wizard and you will see your project has been added to your dashboard once you are done. Bitrise is smart enough to recognize your Android app.
- Go to your dashboard and click on your app. It directs you to build page. All your builds displays in this page. However, before that, you need to make sure you have both of Read and Write permissions. It is important because in an script we will write, we want to push our changes (version name/code) to repo. So, if you have chosen “Auto-add this key” in last step you have only given read access to your build system.
- There are few buttons on top of build page. Click on Settings button. Find “SSH settings” section and click on “Change SSH keypair” button. You will have three options, click on “Change SSH keypair” option. It creates a key for you. Copy this key and click on “Click here” button to save the key (It is important to click save otherwise it doesn’t override your last readonly key).
5. Go to your Github, then repo of your app and click on “Settings” button. Click on “Deploy keys” from left tab. It should looks like following image.
Click on “Add deploy key” button in order to paste the SSH key you got in previous step. Set a title for that such as “Bitrise.io” and past the SSH key in the key box. Make sure you check “Allow write access” checkbox and finally click on “Add key” button. You must have read/write access in order to automate your build.
Setup Release Workflow
Get back to your build page on Bitrise. If you have not built anything yet the page looks like this.
Click on “Well, build away then!” button in the middle of the page. Build configuration screen displays. This is very important window but for the moment just hit “Start build button”. New page opens and your first build starts.
Build takes time depends on number of Tests you have and size of your project. Once done, you get awesome info regard your workflow (we still haven’t talked about it).
Finally your Build page looks like this.
In next story I’ll talk more about Workflow page, how to create Debug/Release workflows and finally how to pass Android version code/name as variables via curl and make a Release build based on these variables.
I hope you enjoyed this article so far, and you found it useful. If so, don’t forget to click the recommend button. Thanks.