Bitrise — An Aggregator for Mobile Apps
Bitrise is a Continuous Integration and Delivery (CI/CD) Platform as a Service (PaaS) focussing on Mobile App development. It is powerful and complex, yet easy to build and maintain, especially in the development and Automation of Mobile apps.
So, the first question that would come to our mind is: “How do I access it?”. That’s where the “easy” part comes into play. Bitrise can be easily integrated with Bitbucket, Gitlab, Github, or simply by just creating credentials using your Email ID. Signing up with any of the Git service providers helps us to connect the Bitrise account with the service provider and access any of the repositories. We can also integrate between the service providers, for e.g., if I sign-up with Github, I can connect my Bitrise account with any of the repositories, not only in Github but on Bitbucket and Gitlab as well. Amazing isn’t it?
The account set-up is sorted, what’s the next thing we want → “How can I add a new App”. Right then, here are the essentials:
Pre-requisites:
- Automation Repo is created
- git submodule is added for the development project by using the following command:
- git submodule add git@bitbucket.org:tideaccount/<dev-project-name>.git
- <dev-project-name> example: universal-app-android
Steps:
- On the Bitrise home page → Click on Add New App (Bitrise_1.png)
2. Select ‘Add New App on Web UI’ (Bitrise_3)
3. On the ‘Create New App’ screen, Choose Account as < organization account>(Bitrise_2)
4. Set the Privacy as ‘Private’ and click on the Next button
5. Select the repository that you want to connect to (Bitrise_4)
6. On the ‘Set-up repository access’ step, Select ‘I need to’ (Bitrise_5)
7. Copy the SSH-key and add this key to the submodule project (dev-project-name) SSH keys
8. Enter the branch name of the dev-project that we want the association for
9. At this stage, Bitrise will run validations with the repository and configurations set above
10. The project build configuration step will be performed by Bitrise.
11. Choose a nice-looking ‘App Icon’ for the App and your App is ready.
Additionally, Bitrise also allows us to set-up
After adding an app, what would anyone want in a CI/CD tool:
“How do I view/customize builds?”
In Bitrise, as soon as an App is added, the first build will be triggered automatically and can be viewed in the ‘Dashboard’ screen on one’s home page. This build (a series of jobs executed in order) can then be further viewed/customized in ‘WorkFlow Editor’. In Bitrise terminology, the jobs are called ‘Steps’, which represent blocks of script execution, and can be arranged on the UI. It can accomplish the various things, mentioned (but not limited to) below:
- Clone your repository
- Build your app
- Run tests
- Pass values to each other (Refer to the next section)
- Send notification messages to stakeholders
As the App was set as ‘Private’ (Refer Step-4 in ‘Adding a new App section’), we should be providing access to Team members to whom we wish to give access to the App. There is no limit on the number of ‘Team members’.
In any CI/CD tool, the most important task would be to know how to pass values from one Step to another, as this would be needed for most of the real-time scenarios. In Bitrise, this can be achieved by using the below command:
“envman add — key <variable-name> — value <value>”
This command, when provided in a script section of a Step, would extract the value and assign it to the variable name. This variable would then be used in other steps.
Fan-out option:
There is a feature within Bitrise that can restrict the amount of time a build could run, for e.g.: if I say that a build should run only for ‘X’ minutes, then the builds would automatically get Aborted after the ‘X’ minutes. In the new dynamic world, we all want fast results and this option would help us keeping our build times low, as again, we want to have lesser build times, and release to the market sooner. So, now the question everyone would have is how to live with it, or do we have a workaround? Yes certainly, Bitrise has an interesting feature called — ‘Fan-out’, what it does is: literally ‘fanning out or in simple terms segregate the steps of a build into 2 different builds and still being integrated to each other.
Let’s take a look at it through a real-time example:
Consider a scenario where we have Unit Tests (or Any other tests) for an application. Generally, we tend to keep the tests as the last step, but still part of the same build. So, once the “.apk” or a “.ipa” file is generated, we execute these tests to quickly do some sort of tests to make sure everything is working. But over a period of time, these tests keep on increasing (based on the features being rolled out) and in the end increasing the build time, resulting in higher build times and by that making the Bitrise build ‘Abort’. In this typical case, what we can do is: “Separate out the tests from the build generation process”.
There will be 2 builds in this case:
Workflow 1
Workflow 2
This is how it is done:
So if I have a workflow created for running testing as ‘Workflow 2’ and I want to include this workflow after the step of generating the file(s) in Workflow 1. Then all we need to do is:
- Open Workflow 1 in Workflow editor
- Click on the step of ‘.apk’ (‘.ipa’) file generation
- Click on the “Add workflow after” button from the above page
- Choose the Workflow 2
From next time, whenever, Workflow 1 is triggered, it will run both workflows.
Bitrise provides us many other features:
- Changing the owner of an app → Log in with current owner → On the Team tab of an App, click on ‘Transfer ownership’
- Monitoring the logs/crashes
- Configuring everything all this using a ‘.yml file’.
A Step can also be Enabled/Disabled conditionally in Bitrise, using the ‘.yml’ file:
This and many other features are covered on https://devcenter.bitrise.io/. Thank you everyone for reading through this.