SlideShare a Scribd company logo
Continuous Integration for your Android projects 
Sergii Zhuk 
Android Developer at DAXX BV 
Kyiv, UA Mobile 2014 
1
Agenda 
•CI in general 
•Popular CI systems and tools 
–Travis CI 
–Circle CI 
–Jenkins 
–Continuous Deployment 
•Demo projects 
•Q&A 
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
•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
Practical outcomes that CI provides 
5 
Illustration from https://www.jetbrains.com/teamcity/features/deployment.html
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
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
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
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
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
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
•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
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?
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
Jenkins: overview 
•Hudson  Jenkins 
•Open-Source 
•Java WebApp in container 
•Should be hosted on your private server 
•Multiple users, matrix permissions 
15
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
•Extremely flexible 
•Hundreds of plugins 
17 
Jenkins: configuration options
Jenkins: useful plugins 
•Android Lint plugin 
•HTML Report plugin 
•JaCoCo plugin 
•HockeyApp plugin 
•Google Play Android Publisher plugin 
18
Continuous deployment 
•Submit latest builds to test devices 
•TestFlight RIP 
19
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
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
Demo: Example Android project 
•Simple 
•Gradle-based 
•Robolectric unit tests 
•Hosted on GitHub 
22
Demo 
23
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
25 
Q&A
Thanks! 
Contact me: 
sergey.public@gmail.com 
http://ua.linkedin.com/in/sergiizhuk 
http://fb.com/sergii.zhuk 
26

More Related Content

Continuous Integration for your Android projects

  • 1. Continuous Integration for your Android projects Sergii Zhuk Android Developer at DAXX BV Kyiv, UA Mobile 2014 1
  • 2. Agenda •CI in general •Popular CI systems and tools –Travis CI –Circle CI –Jenkins –Continuous Deployment •Demo projects •Q&A 2
  • 3. 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
  • 4. •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
  • 5. Practical outcomes that CI provides 5 Illustration from https://www.jetbrains.com/teamcity/features/deployment.html
  • 6. 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
  • 7. 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
  • 8. 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
  • 9. 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
  • 10. 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
  • 11. 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
  • 12. •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
  • 13. 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?
  • 14. 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
  • 15. Jenkins: overview •Hudson  Jenkins •Open-Source •Java WebApp in container •Should be hosted on your private server •Multiple users, matrix permissions 15
  • 16. 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
  • 17. •Extremely flexible •Hundreds of plugins 17 Jenkins: configuration options
  • 18. Jenkins: useful plugins •Android Lint plugin •HTML Report plugin •JaCoCo plugin •HockeyApp plugin •Google Play Android Publisher plugin 18
  • 19. Continuous deployment •Submit latest builds to test devices •TestFlight RIP 19
  • 20. 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
  • 21. 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
  • 22. Demo: Example Android project •Simple •Gradle-based •Robolectric unit tests •Hosted on GitHub 22
  • 24. 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
  • 26. Thanks! Contact me: sergey.public@gmail.com http://ua.linkedin.com/in/sergiizhuk http://fb.com/sergii.zhuk 26