This tutorial contains information about the usage of the Jenkins build server to build Android appplications.
Jenkins supports the automatic building and testing of Android applications. To create a build job on Jenkins, you need to have a working build setup. The Android tooling generates automatically a valid Gradle build file, which can be used in Jenkins.
The Android SDk must be available on the server. If you build server has no display server, you need to install the Android SDK from the command line. You also need to configure the location for the Android SKD for Jenkins.
# download the Android SDK via wget # for the correct URL see http://developer.android.com/sdk/index.html # and look in the section "SDK Tools Only" wget <link from the above website> # example # wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz # unpack it tar zxvf filename # Add the new directory to your patch # assumes you exported it to /opt/ # this must be set for the Jenkins user export ANDROID_HOME="/opt/android-sdk-linux" export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH" // run this as Jenkins user android update sdk --no-ui
android list targets command to see what ABIs are installed.
If no are listed you need to install one, as demonstrated in the following example:
android update sdk --all --filter sys-img-armeabi-v7a-android-23 --no-ui --force
You need the follwing plug-ins to build Android application with Jenkins:
Git Plugin - if Git is used for the project sources
Android Emulator Plugin - supports starting and unlocking an Android emulator and blocks the build until the emulator has started. Required for running tests.
To create an Android build job on Jenkins, select New Job, and enter a job name. Select the Build a free-style software project option.
You now configure from where the source should be cloned.
Configure you desired build trigger. In the above screenshot, the job would check the Git repository every 15 mins.
Add a Gradle build step to your Jenkins jobs.
That is it, you should be able to run your Android build.
To run your instrumentation tests on your device you also need to configure a virtual device.
Ensure that you do not select the Show emulator window option because your job should not depend on the availability of a display server.
To run your tests and your instrumentation tests use the
test connectedAndroidTest target.
Android Emulator Plugin - supports a new job with the Build multi-configuration project option. This option allows you to test multiple emulator configurations at the same time. You can, for example, test different languages, densities, screen resolutions, etc.
Typically you have two Jobs. One for a simple build and test run and a multi-configuration project to test the build on different device configurations.
Another useful plug-in is the Lint plug-in which allows to run your Lint checks via Jenkins. See https://wiki.jenkins-ci.org/display/JENKINS/Android+Lint+Plugin for details.
|TRAINING||SERVICE & SUPPORT|
The vogella company provides comprehensive training and education services from experts in the areas of Eclipse RCP, Android, Git, Java, Gradle and Spring. We offer both public and inhouse training. Whichever course you decide to take, you are guaranteed to experience what many before you refer to as “The best IT class I have ever attended”.
The vogella company offers expert consulting services, development support and coaching. Our customers range from Fortune 100 corporations to individual developers.
Copyright © 2012-2016 vogella GmbH. Free use of the software examples is granted under the terms of the EPL License. This tutorial is published under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Germany license.