Bitrise- Getting started with Android Integration Part-2
I hope you have setup your project into the Bitrise using “Part-1”. In this tutorial, we’ll focus on workflow configuration.
After completing the project setup, we are able to check the workflow option from the dashboard.
You can see the Primary Workflow is already created.
We are moving with the primary workflow here. We can add more steps inside the default workflow to generate the build.
Order of the Steps matter! (From the official doc.)
- To cache Gradle dependencies, keep the Bitrise.io Cache:Pull step as the first and the Bitrise.io Cache:Push Step as the very last step in your Workflow!
- Right after our Do anything with Script Step, the Install missing Android SDK components will take care of installing the missing Android SDK components that your project might be lacking.
- Change Android versionCode and versionName Step must be inserted BEFORE the Android Build Step as the former makes sure you will upload the build with the right version code and version name to Google Play Store.
- Android Lint and Android Unit Test Steps must be inserted BEFORE the Android Build Step to test your code and debug before building your build.
- Android Sign Step must be AFTER the Android Build Step as the latter builds your project so that you have an APK ready to be signed with the Android Sign Step. Make sure that this Step is BEFORE any deploy Step so that you can upload an authorised project.
As we can see in the primary workflow, there is no Android Build Step that would build-out project. So, we are now adding “Android Build” to the workflow by clicking the “+” button below the “Bitrise.io Cache:Push”
After adding “Android Build” to the workflow, please add your module name (like ‘app’) inside the highlighted box.
Now add the “Gradle Runner” into the workflow below the “Android Build” same as above.
In the config section, add ./gradlew
inside the “gradlew file path” highlighted box.
Arrange the workflow steps by moving “Deploy to Bitrise.io — Apps, Logs, Artifacts” to the bottom of “Gradle Runner”
Now all set to generates the build. Rebuild your project and you are able to see your builds inside the “APPS AND ARTIFACTS”. You are able to directly download the apk from the list.
We can also trigger the message on completing the build process to the Slack or Microsoft Teams. Just add the option at last of the workflow and configure it with your Slack or Microsoft Teams. We will get the message after successfully generating the build.
We can set/update environment variables from the Workflow Editor’s top right navigation “$ Env Vars” option
We can add the trigger to generate the build when code is pushing to the particular branch.
Here we have “*” as a default option. We can add any branch name by which we want to generate the build on a new push. Here we should choose “develop” as a Push branch.
We can also add the trigger on a pull request and based on the tag as you can see in the above screenshot.
Hope you have enjoyed reading this as much as I enjoyed writing it.
Do you think this tutorial will be of help to someone? Do not hesitate to share. If you liked it, smash the clap below so other people will see this here on Medium.