Continuous Android Deployment with Bamboo and HockeyApp

November 25, 2013

Making and Distributing Builds Manually is Boring

At MichiganLabs, we like to automate away redundant/mindless work so we can focus on providing value to clients and working on the interesting and difficult problems.

One of the very common tasks we do is build software; sometimes to give to clients, sometimes to provide versions for internal testing, sometimes just to see if it will build. Deployment to mobile devices can be complicated by the number of different devices that need to have the app downloaded and installed. In addition, the use of Git provides effortless branching but it can be difficult to keep track of all the different branches and what is currently being tested.

Enter Bamboo…

Atlassian Bamboo is a great build server which has tight integration with our instances of Jira (issue tracker) and Stash (Git repository). Bamboo can be configured to automatically track all the branches in Stash and build them. The integration is great and it makes it easy to see the status of each build.

Followed by HockeyApp

Once a build is complete, it’s sitting on the Bamboo server with no one able to access it except through the web interface. It’d be nice if a user could download the latest beta or an internal tester could put down the latest version. One option would be to upload the binary to a web server but that doesn’t provide much in the way of authentication or authorization and it can be hard to track versions and branches. Often, we only want clients to see beta builds but internally we should see all feature builds as well.

HockeyApp is a great service similar to TestFlight that allows Android and iOS apps to be uploaded and distributed. They provided a mobile app for users to see the latest build and provide feedback. There are a few features that set HockeyApp apart from other services we’ve looked at:

  • Ability to tag builds to restrict who can see them
  • Programmatically add release notes which we use to add feature branch name and commit number to each upload

Our Configuration

Setting the Android Version using Maven

Our Android projects use Maven for dependency management and builds. Bamboo has a plugin which runs Maven targets, so importing them in was straightforward. One of the things we wanted to do was have the branch name included in the Android version string so that a user could easily identify what branch they had installed. We didn’t want to edit the AndroidManifest.xml manually for each build, so we turned to the plugin to update it.

Bamboo’s Maven targets is

clean android:manifest-update install -Dandroid.manifest.versionName=${bamboo.repository.branch.name}

The android:manifest-update tells Maven to update the local manifest before it builds and passing in the versionName property sets the value. Bamboo has quite a few environment variables that can be used through the build configuration, ${bamboo.repository.branch.name} is the branch name of the current build. Now, every APK that is generated has the branch name embedded right in it.

Uploading to HockeyApp

Atlassian advertises that their iOS Plugin supports uploading to HockeyApp but doesn’t mention anything about using it with Android. Fortunately, the upload task doesn’t verify that file being uploaded is actually an iOS archive, so the plugin can be used just fine with Android APKs. It’s as simple as entering the API key and adding the task to the build stage.

The plugin allows release notes to be provided. Here too, we make use of Bamboo’s environment variables to provide valuable information. Our current settings are

Branch: ${bamboo.repository.branch.name}

Commit: ${bamboo.repository.revision.number}

Future Enhancements

Automated Tagging

The HockeyApp plugin currently doesn’t allow automated setting of tags so we manually have to go in and set them when we want to release to clients. This works fine since it doesn’t take long to do. HockeyApp has a public api so we can add a stage in the Bamboo publish process at some point.

Ready to get started?

Call us at 616-594-0269 or send us a note below.
Visit our office @ 452 Ada Drive SE Suite 300 Ada, Michigan 49301
Send us an e-mail @ info@michiganlabs.com