Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Continuous Integration for your Android projects

Sergii Zhuk
November 22, 2014

Continuous Integration for your Android projects

Slides from my talk about CI, presented at UAMobile 2014, http://uamobile.org/2014/

More Android stuff:
https://medium.com/@sergii
https://twitter.com/sergiizhuk

Sergii Zhuk

November 22, 2014
Tweet

More Decks by Sergii Zhuk

Other Decks in Programming

Transcript

  1. Agenda • CI in general • Popular CI systems and

    tools – Travis CI – Circle CI – Jenkins – Continuous Deployment • Demo projects • Q&A 2
  2. Continuous integration • Every developer keeps his work-in-progress continually integrated

    with every other developer • Requires build to be automated and self- testing • Makes results of the latest build visible 3 http://martinfowler.com/articles/continuousIntegration.html
  3. • Making a build (periodically, triggered) • Running a unit

    and integration tests • Returning artifacts, test reports, code coverage reports etc. • Notifications • Deploying to continuous deployment tools 4 Practical outcomes that CI provides
  4. Travis CI: overview • Hosted, open-source • GitHub-only integration •

    Free for public GitHub repositories, starting from $129/mo for private ones • Easy to setup: always one .travis.yml file • Officially supports Android platform since 2014 6
  5. Travis CI: setup • Hosted Travis Webapp setup, add your

    GitHub account • .travis.yml configuration file • Validate your configuration file http://lint.travis-ci.org/ [yaml syntax] 7
  6. Travis CI: configuration options (1) • Programming language your project

    uses • Commands/scripts you want to be executed before each build (e.g. install dependencies) • Command is used to run test suite • Emails, Campfire and IRC rooms to notify about failures 8
  7. Travis CI: configuration options (2) • Code coverage (for Java/Android):

    external hosted tool Coveralls, uses JaCoCo reports, from $5/mo • Limited functionality in uploading artifacts, but friendly with Amazon S3 • Scheduled builds only by external tool 9
  8. Travis CI: configuration example language: android android: components: # The

    BuildTools version used by your project - build-tools-19.1.0 # The SDK version used to compile your project - android-19 before_install: - chmod +x gradlew install: - ./gradlew assemble script: - ./gradlew test # For Robolectric tests 10
  9. Circle CI: overview • Hosted service • GitHub-only integration •

    Starts from $19/mo • Easy to setup: 2 additional files for Android • SSH access to build VM for 30 minutes after build 11
  10. • What programming language your project uses • What commands/scripts

    you want to be executed before each build (e.g. install dependencies) • What command is used to run test suite • Artifacts to collect • Nightly builds (using extra script) 12 Circle CI: configuration options
  11. Circle CI: configuration (1): circle.yml 13 machine: environment: ANDROID_HOME: /usr/local/android-sdk-linux

    dependencies: cache_directories: - ~/.android - ~/android override: - bash install-dependencies.sh test: override: - chmod +x gradlew - ./gradlew assemble test Looks like Travis CI, doesn’t it?
  12. Circle CI: configuration (2): dependencies script export PATH="$ANDROID_HOME/platform- tools:$ANDROID_HOME/tools:$PATH" DEPS="$ANDROID_HOME/installed-dependencies"

    if [ ! -e $DEPS ]; then echo y | android update sdk -u -a -t android-19 && echo y | android update sdk -u -a -t platform-tools && echo y | android update sdk -u -a -t extra && echo y | android update sdk -u -a -t build-tools-19.1.0 && touch $DEPS fi 14
  13. Jenkins: overview • Hudson  Jenkins • Open-Source • Java

    WebApp in container • Should be hosted on your private server • Multiple users, matrix permissions 15
  14. Jenkins: setup • Network-enabled server • Install Jenkins bundle with

    servlet container • Install Android SDK and support repos • Add Jenkins plugins for Git, Gradle etc. • Add your Git keys 16
  15. Jenkins: useful plugins • Android Lint plugin • HTML Report

    plugin • JaCoCo plugin • HockeyApp plugin • Google Play Android Publisher plugin 18
  16. Continuous deployment tools HockeyApp Appaloosa TestFairy Play Store Apphance Continuous

    deployment API X X X X X Mobile version X X X Distribution list permissioning X X X X Cost First month free, next from $30/mo Free, limited to 1 app and 10 users Free Registration fee Free, limited to 1 app and 50 devices 20 http://www.thoughtworks.com/insights/blog/testflight-alternatives-android
  17. Some other CI products • CruiseControl : open-source, last updated

    in 2010 • Ship.io (ex CIsimple) : hosted, easy to setup, but still a startup with bugs & limited functionality • TeamCity by JetBrains : good IntelliJ products integration, server-based, has free version • Atlassian Bamboo : good JIRA integration, starts from $10/month 21
  18. Useful links • General http://martinfowler.com/articles/continuousIntegration.html https://devblog.toopher.com/2013/07/05/enabling-travis-ci-for-fun-and-profit/ http://ruenzuo.github.io/continuous-delivery-on-android-part-ii/index.html • Jenkins setup

    http://sanketdangi.com/post/62715793234/install-configure-jenkins-on-amazon-linux https://www.digitalocean.com/community/tutorials/how-to-build-android-apps-with-jenkins http://stackoverflow.com/questions/18045712/gradle-build-android-project-could-not- resolve-all-dependencies-error-but-i-t 24