Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

A step-by-step tutorial for continuous integration with Jenkins on a Red Hat Mobile Native Android application: Part 2

August 11, 2016
Juana Nakfour
Related topics:
Java
Related products:
Red Hat build of Node.js

    In part one of our series, we established the process around creating an Android application using Red Hat’s Mobile Application Platform and adding unit tests. Now, we’ll walk through how to use Jenkins for continuous integration on this app.

    Pre-requisites for this tutorial

    1. RHMAP Instances
    2. Jenkins installed on Fedora
    3. Android Studio setup on a development machine.

    The following are the topics covered in today’s post:

    1. Setup Jenkins to run Android Unit Test
    2. Install Jenkins plugins
    3. Install Android SDK and Tools
    4. Setup SSH on RHMAP and Jenkins
    5. Create an Android Emulator from command line
    6. Create a Jenkins project to run Android Unit Tests

    Setup Jenkins to run Android Unit Test

    This tutorial assumes Jenkins and git tools are installed on a Fedora machine.

    Install Jenkins plugins

    We need to install all the plugins needed to run Android build. From the Jenkins portal go to Manage Jenkins → Manage plugins→ Available and select the following

    1. Android Emulator Plugin
    2. Git plugin
    3. Gradle Plugin

    Click Install without restart.

    Install Android SDK and Tools

    The first step is to download and install the android sdk and tools. Follow these steps:

    1. cd /opt
    2. wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
    3. tar zxvf android-sdk_r24.4.1-linux.tgz
    4. rm android-sdk_r24.4.1-linux.tgz

    Now that the android sdk installed, we need to setup the environment variables to point to the sdk. In a terminal either enter

    1. export ANDROID_HOME="/opt/android-sdk-linux"
    2. export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"

    Or depending on your terminal shell type you can edit /etc/profile.d/android.sh and add in the above commands.

    Next we need to run commands to install different android tools:

    1. Update the android sdk and accept agreements
      1. android update sdk --no-ui
    2. Install the Android SDK build-tools
      1. Find the item number
        1. android list sdk --all
        2. Look for a matching version xx.xx.xx to your build.gradle file
      2. Install the right version build tools

         

        1. android update sdk -u --all --filter <#item number >
    3. Repeat the same process to install the correct Android SDK, by matching the SDK number in gradle.build in compileSdkVersion
    4. Give Jenkins access to the sdk
      1. sudo chmod -R 755 /opt/android-sdk-linux
    5. We also need to setup Jenkins to point to the sdk. From the jenkins web portal Manage Jenkins→ Configure system→ Android sdk root→ type in /opt/android-sdk-linux and select “Automatically install Android components when required”
    6. Add a specific gradle version to Jenkins configuration
        1. Gradle plugin in Jenkins is not enough, you must also go to:
        2. Jenkins→ Manage Jenkins→ Configure Jenkins→ Configure system.
        3. Under “Gradle Installations” type in name (it appears as version in project configuration), check “Install automatically” and select version. Then you can select that “Gradle version” in project configuration.
    7. If your fedora machine is running on a 64 bit machine you need to install 32bit libraries
      1. yum install libstdc++.i686
      2. yum install zlib.i686
    8. Install JDK and set JAVA_HOME
      1. yum install java-1.8.0-openjdk-devel
      2. export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.91-0.b14.el7_2.x86_64/

    Setup SSH on RHMAP and Jenkins

    For Jenkins to be able to perform a git clone of our RHMAP application we need to create and upload the SSH public key to RHMAP. In a terminal on your Fedora machine generate a new key using ssh-keygen and when asked enter/var/lib/jenkins/.ssh/<anyname> as the location of the keys. Now that the keys are generated we need to make sure they are owned by Jenkins and not the user we are logged into Fedora.

    Run the following command:

    chown Jenkins /var/lib/jenkins/.ssh/<anyname>.*

    Now that we have keys generated, log into RHMAP instance and go to admin→ users →Create and create a new user ID = jenkins with a valid password an email address. Give user Jenkins the right access to read any projects needed

    Then logout and login as “Jenkins” user and upload the public key in Settings→ SSH Key Management→ Add New Key. At this point we have SSH git access setup on RHMAP portal but we still need to create an SSH profile in Jenkins. From the Jenkins portal go to Jenkins→ Credentials→ Global Credentials→ Add Credential→ Fill in the form as seen below

    Create an Android Emulator from command line

    On your fedora machine we need to create an android emulator that can be used by Jenkins. In a terminal run

    1. List the available targets
      1. android list target
    2. Create an avd for one of the targets, this command choses id=17 for abi armeabi-v7a
      1. android create avd -n android-23-emulator -t 17 --abi default/armeabi-v7a

    Create a Jenkins project to run Android Unit Tests

    Time to create a new Jenkins project that can build and run Android tests. From the Jenkins portal click New Item→ Freestyle project and fill in the fields as shown below

    1. Set Git to use jenkins credentials
    2. Use Gradle Wrapper with Tasks clean, assemble, test, connectedAndroidTest
    3. Install APK file
    4. Archive artifacts
    5. Publish JUnit test result reports for both Android unit test and Instrumented unit tests

    Save configuration and Build Now. If the build succeeds from the Status page you should be able to see your artifacts and test results.

     

     

     

     

    Last updated: October 31, 2023

    Recent Posts

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.