How to build Cordova-based Android project on bitrise.io

Bitrise is a Mobile Continuous Integration and Delivery service. It has a lot of integrations and the number of integrations increases very fast. The best thing about integrations is that they are completely open source.

Prehistory

Bitrise provides range of stacks, and you can decide which one to choose for your project. I’m doing Android development and everything related to Android is automatically interesting to me. I wanted to contribute to bitrise-steps something related to Android. Inspiration came from bitrise-user-voice and I’ve chosen Install Cordova and Ionic. Both Cordova and Ionic platforms were new to me, which even more increased my interest.

As all Android jobs on bitrise.io are running in isolated docker containers, all what I needed to do is to extend existing bitrise docker images and add Cordova support.

It took me 2-3 weeks to prepare docker image for bitrise.io with Cordova related dependencies installed. It’s a bit long period of time, as I had problems with freezing docker containers on my local PC (every time when cordova build command was executed, I’ve got frozen docker container). I’ve tested my docker image on Mac OS a lot - and got frozen container on cordova build. Than I’ve configured ubuntu-14.04 using Vagrant, installed docker in ubuntu-14.04 VM - same effect. But I knew that configuration is ok, as I read tons of articles about docker images already, checked some other docker images which have Cordova related dependencies.

Finally, I’ve published docker-android-cordova image to Docker Hub and decided to give a last try to my docker image at bitrise.io. And it worked! :open_mouth:

David Blane

How to build Cordova-based Android project on bitrise.io using dedicated docker image

  1. Add your Cordova Android project to bitrise.io (”+ Add new app” button).

    Add new app

  2. Follow the steps and add your application. In this case I’m using Cordova Android Sample application. It’s a default Android application generated with cordova create command + some cordova android plugins.

    Add new app 2

  3. At "Project build configuration" step choose "Configure it manually" and select Android platform.

    Project build config manual

  4. Enter following parameters (see screenshot). The only important information here is the branch name. We’ll modify or even delete Gradle tasks further in workflow configuration. Pressing "I'm ready" should finish project configuration process.

    Project build config params

  5. Navigate to project "Settings" tab.

    Cordova project settings

  6. Scroll down to stacks section and enter vgaidarji/docker-android-cordova:latest into "Docker image to use". This is my custom docker image which has all required tools listed for Cordova Android projects.

    Stacks section

  7. Go to "Workflow" tab and select "Manage workflows"

    Stacks section

  8. In “edit mode” remove default "Gradle" step, and add "Cordova Android" between "Git clone repository" and "Deploy to bitrise.io" steps.

    Remove gradle step

    Add cordova step

  9. By default, "Cordova Android" step will execute following command
    cordova build android --verbose. Feel free to modify parameters. To be honest, I didn’t test all the commands, but they should work for sure.

    Cordova step config

  10. Press "Save" button at left. Now we’re ready to build our project.

    Save config

  11. Navigate to "Builds" tab and press "Start build". The build will use our default workflow, with "Cordova Android" step, and if everything is ok, you should see something like:

    Build success

    Configurations! We did it! :beer: + :pizza:

Note: The one thing is that in this example we use custom docker image in order to build “Cordova Android” project at bitrise.io. In the near future, all Cordova related tools will be preinstalled in bitrise-base and/or bitrise-android docker images. It means that we’ll not need anymore additional docker image and “Cordova Android” projects should be supported by default.

comments powered by Disqus