AndroDev99
Lurker
Original Source can be found here: https://xamoom.com/en/2016/05/setup-a-local-jenkins-for-your-android-project/
Install Jenkins
You can install jenkins via their installer (https://jenkins.io/) or homebrew(http://brew.sh/). If you want to have a mac app in your dock like me, here is a github project with a bundled Jenkins App. (https://github.com/stisti/jenkins-app)
After installing and starting Jenkins you should be able to open your browser and go to jenkins normally with the urlhttp://localhost:8080/.
Install Plugins
Before we can start with building and testing we need some plugins.
Install the following plugins:
Setup ANDROID_HOME variable
Setup Gradle
Create the Jenkins job
Back at the main site of Jenkins we now create a new Jenkins job for our project.
You will be redirected to the configuration page of your Jenkins job.
Here we will configure everything we need to build our project and test it.
Jenkins Job Configuration
First we will configure our connection to github.
Repository URL Copy here the git repository url from your project
Credentials Reuse or create new credentials for your git
Branches to build Insert your branch you want to build
Now we define when Jenkins will get new builds from github.
Here we use “H/15 * * * *“ to check every 15 minutes.
Now we configure an Android emulator, that will get started to run our tests.
Android OS Version Numeric Android version
Screen density Density e.g. 160, mdpi, hdpi
Screen resolution Resolution to test on e.g. 480×800, WVGA
Device locale Language region pair existing on the device
SD card size Size of emulator sd card
Target ABI Android system
Emulator name suffix Optional suffix
Under build we add now “Invoke Gradle script”
We select “Use Gradle Wrapper” and check “Make gradlew executeable” and “From Root Build Script Dir”.
In the field “Tasks” we insert:
Tasks clean test connectedCheck build
Click save and we are finished!
First run
Now push a new commit to your git and wait for Jenkins to finish the build.
If the build fails, look at the
. You will find there why the build failed and can fix your problem.
If your build passes. Yipieh
Conclusion
Now you should have a working Jenkins job for you Android project. You can use it for unittests, integration tests and UI-Tests.
You can also extends Jenkins to:
Install Jenkins
You can install jenkins via their installer (https://jenkins.io/) or homebrew(http://brew.sh/). If you want to have a mac app in your dock like me, here is a github project with a bundled Jenkins App. (https://github.com/stisti/jenkins-app)
After installing and starting Jenkins you should be able to open your browser and go to jenkins normally with the urlhttp://localhost:8080/.
Install Plugins
Before we can start with building and testing we need some plugins.
- Click “Manage Jenkins”
- Click “Manage Plugins”
- Under the tab “Available” you can search for plugins
Install the following plugins:
- Git plugin
- Android Emulator Plugin
- Gradle plugin
Setup ANDROID_HOME variable
- Click “Manage Jenkins”
- Click “Configure System”
- Scroll to “Global properties”
- Add a key-value pair with name “ANDROID_HOME” and the path to your Android SDK as value
Setup Gradle
- Click “Manage Jenkins”
- Click “Configure System”
- Scroll to “Gradle”
- Fill in the form as follows:
- name – “Gradle”
- GRADLE_HOME – the path to your gradle
Create the Jenkins job
Back at the main site of Jenkins we now create a new Jenkins job for our project.
- Click “New Item”
- Insert your Item Name
- Choose Freestyle Project
- Click “Ok”
You will be redirected to the configuration page of your Jenkins job.
Here we will configure everything we need to build our project and test it.
Jenkins Job Configuration
First we will configure our connection to github.
Repository URL Copy here the git repository url from your project
Credentials Reuse or create new credentials for your git
Branches to build Insert your branch you want to build
Now we define when Jenkins will get new builds from github.
Here we use “H/15 * * * *“ to check every 15 minutes.
Now we configure an Android emulator, that will get started to run our tests.
Android OS Version Numeric Android version
Screen density Density e.g. 160, mdpi, hdpi
Screen resolution Resolution to test on e.g. 480×800, WVGA
Device locale Language region pair existing on the device
SD card size Size of emulator sd card
Target ABI Android system
Emulator name suffix Optional suffix
Under build we add now “Invoke Gradle script”
We select “Use Gradle Wrapper” and check “Make gradlew executeable” and “From Root Build Script Dir”.
In the field “Tasks” we insert:
Tasks clean test connectedCheck build
Click save and we are finished!
First run
Now push a new commit to your git and wait for Jenkins to finish the build.
If the build fails, look at the
If your build passes. Yipieh
Conclusion
Now you should have a working Jenkins job for you Android project. You can use it for unittests, integration tests and UI-Tests.
You can also extends Jenkins to:
- Generate a *.apk
- Send Email or Slack notifications
- Calculate Code Coverage
- and a lot more …
Last edited: