Genymotion & Jenkins integration

genymotion-jenkins-integration

This document explains how to use Genymotion on a Jenkins continuous integration server, in order to run the instrumented tests of your Android application.

Using the Gradle plugin for Genymotion in an Android project

To use Genymotion on a continuous integration server, you must automate the launch via the Gradle plugin. This tool will create, confgure and launch automatically devices, just before your tests task. You can refer to the documentation of the Gradle plugin for Genymotion.

Once the Android project is ready, you must configure the server so that it can receive this kind of task.

Prerequisites of the server hosting tests

Running Genymotion

To run Genymotion instances, your machine must observe the following prerequisites:

  • The minimum hardware configuration:
    – VT-X or AMD-V capable CPU (not a VM, but bare metal)
    – 10 Go disk space
    – OpenGL 2.0
    – 4GB RAM
  • The server must have a running and functional X server. You cannot use a command line only OS.

Your integration server (hosting Jenkins) does not need to run Genymotion itself, but you must have a computer accessible on the network, able to run Genymotion instances. To do so, you must use the method of nodes, detailed below.

Installing Genymotion with gmtool
In this context, the use of Genymotion is automated, you must therefore use gmtool binary. Once the installation is performed, check that instances are launched directly on the destination machine to grasp the possible dependencies to be installed. Also, if an error related to incompatible Qt libs arises, follow the procedure given in the FAQ.

Installing the Android SDK
To run a build of an Android project, the host computer must have the Android SDK installed. It is available here. The installation must be performed on the computer on which instrumented tests will be run. Once the Android SDK is downloaded and extracted, you must install the required additional libraries, according to your Android project.

This can be done in command line via the binary

<ANDROID_HOME>/tools/android

as briefly explained here.

 

Note: It is possible to automate the acceptance of the license during a lib installation by injecting “yes” into the command like this:

(while true; do sleep 1; echo yes; done) | android update sdk ...

 

Caution: Command

android sdk update -t 1,4,...

causes problems if we use indices presented in

android list sdk.

Instead, use identifiers given in command

android list sdk --extended.

 

Adding the Android project to the Jenkins server

You can now add your project to the Jenkins server as you would usually do.

If your server is able to run Genymotion, you only need to run the dedicated Gradle task (“connectedAndroidTest” or other) and everything should run seamlessly.

If the machine hosting Jenkins is not able to run Genymotion, you must delegate the task to a node on your network.

Adding and configuring a node

A Jenkins node allows to move the processing of a Jenkins build to another PC than the one hosting the CI server. Here, we’ll be using a node to run a build and then run the instrumented tests of an Android application.

To add a node to the server, please follow the official documentation.

Once this is done, you must add the following environment variables:

  • ANDROID_HOME, containing the path to the Android SDK.
  • DISPLAY (required only on  Linux), containing the display identifier in charge of the Genymotion interface.

Note: In many cases, the variable will contain :0. It designates the first X client launched during startx. To know the variable to use, open a command prompt and run the command

echo $DISPLAY

It will return the field content.

Finally, in the configuration of the Android project to build, you must indicate the slave on which you want to run builds.

To do so, you only need to check Restrict where this project can be run and indicate the node(s) on which you want it to be run, as shown below:

Capture du 2015-03-03 16:35:21

Congratulations! You now have an integration server able to run your instrumented tests on Genymotion.

Select Product Portal

SaaS Platform

Access to our SaaS solution and use virtual machines in the cloud on any web browsers.

Or

Or

Desktop Platform

Access to manage your Genymotion Desktop licenses, your invoices and account information.

Select a Cloud provider Marketplace

Genymotion Device Image for Cloud providers
- Private Offer -

Genymotion Desktop for Business
- Get a Quote -

Genymotion SaaS
- Increase Maximum Simultaneous devices -

Personal Use - Free

Genymotion Desktop for personal use is not suitable for trial or POC: you will not get any assistance and some features will be disabled. If you have already selected “personal use” and wish to get a trial license, please contact our Sales at [email protected].

Technical support is not available with Genymotion Desktop free edition for personal use. For more details, please refer to Genymotion conditions of use (Personal Use).

The following features are not available in personal use mode:

Follow these steps to get Genymotion Desktop and activate personal use mode:

  1. Go to the Download page and get the latest version for your system.
  2. Follow the instructions from Genymotion Desktop quickstart guide to install Genymotion Desktop.
  3. Launch Genymotion and click CREATE to create an account. You should receive an activation email within an hour. If not, make sure to check your spam.
  4. After activating your account, return to Genymotion and log in with your credentials.
  5. Select personal use when prompted.
  6. Read Genymotion Desktop quickstart guide carefully to setup Genymotion for your needs.