1. Download our Official Android App: Forums for Android!

Apps Setup a local Jenkins for your Android project

Discussion in 'Android Development' started by AndroDev99, May 13, 2016.

?

Was this post helpful?

  1. Yes

    1 vote(s)
    100.0%
  2. No

    0 vote(s)
    0.0%
  1. AndroDev99

    AndroDev99 Lurker
    Thread Starter
    Rank:
    None
    Points:
    6
    Posts:
    2
    Joined:
    May 13, 2016

    May 13, 2016
    2
    3
    6
    Male
    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.

    1. Click “Manage Jenkins”
    2. Click “Manage Plugins”
    3. Under the tab “Available” you can search for plugins
    [​IMG]

    Install the following plugins:

    • Git plugin
    • Android Emulator Plugin
    • Gradle plugin
    You may need to restart your jenkins.

    Setup ANDROID_HOME variable
    1. Click “Manage Jenkins”
    2. Click “Configure System”
    3. Scroll to “Global properties”
    4. Add a key-value pair with name “ANDROID_HOME” and the path to your Android SDK as value
    [​IMG]

    Setup Gradle
    1. Click “Manage Jenkins”
    2. Click “Configure System”
    3. Scroll to “Gradle”
    4. Fill in the form as follows:
      • name – “Gradle”
      • GRADLE_HOME – the path to your gradle
    (My path is “/Applications/Android Studio.app/Contents/gradle/gradle-2.10”)

    Create the Jenkins job
    Back at the main site of Jenkins we now create a new Jenkins job for our project.

    1. Click “New Item”
    2. Insert your Item Name
    3. Choose Freestyle Project
    4. Click “Ok”
    [​IMG]



    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
    [​IMG]

    Now we define when Jenkins will get new builds from github.
    Here we use “H/15 * * * *“ to check every 15 minutes.



    [​IMG]

    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
    [​IMG]

    Under build we add now “Invoke Gradle script”


    [​IMG]

    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 [​IMG]. You will find there why the build failed and can fix your problem.

    If your build passes. Yipieh [​IMG][​IMG][​IMG]



    [​IMG]

    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 …
    If you want to create the same for iOS you can check out: How to setup a local Jenkins for your iOS
     

    Advertisement

    #1 AndroDev99, May 13, 2016
    Last edited: May 13, 2016
  2. El Presidente

    El Presidente Beware The Milky Pirate!
    Moderator
    Rank:
     #5
    Points:
    3,118
    Posts:
    32,075
    Joined:
    Jan 3, 2011

    Jan 3, 2011
    32,075
    23,990
    3,118
    Scotland
    AndroDev99, LV426 and scary alien like this.
  3. AndroDev99

    AndroDev99 Lurker
    Thread Starter
    Rank:
    None
    Points:
    6
    Posts:
    2
    Joined:
    May 13, 2016

    May 13, 2016
    2
    3
    6
    Male
    Thank you for your concern, I adjust the post immediately.
     
    scary alien, LV426 and El Presidente like this.

Share This Page

Loading...