Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Dec 10, 2019 14:07

You can use the Gradle plugin as part of a Jenkins CI controlled job. This section guides you through the process of integrating your automation scripts with Jenkins based on your use case, including the option to utilize a local Android project.

Scenario 1 | Android Studio

An Android Studio (AS) project folder is hosted in a Git Repository that is accessible to Jenkins (you can access it here). The AS project is already configured to work with the Gradle plugin, meaning the build.gradle and config.json files are defined properly, as described in the Espresso section.

Steps
  1. Create a new Jenkins job.
  2. Add the Source Code Management information for the Git repository location of the project.

    To utilize a locally available Android project, select None. Then select the Copy data to workspace checkbox and provide the path to the folder.
  3. Add the build step using the Gradle wrapper application from the AS project to activate the plugin.
  4. Run the job and get the Gradle output in the console logs.

Scenario 2 | Standalone mode with Gradle plugin

You run Gradle from Jenkins using the Jenkins Gradle plugin. Application debug and Espresso test .apk files exist in the local file system. An example configuration file is available here.

Steps
  1. Create a new parameterized Jenkins job.
    The job uses the Perfecto Lab URL, security token, build.gradle file, and configuration file (configFile.json) as parameters to the job.
  2. Add a string parameter with your Perfecto Lab URL as the default value.
  3. Add a string parameter with your security token as the default value.
  4. Add an Invoke Gradle script build step where we run the plugin task with the command. Also add the job name and build number in the command. These parameters allow you to filter the specific tests in the reports.
    For more information on the relevant Gradle parameters, see Android configuration parameters for the Gradle Plugin.

    perfecto-android-inst -PcloudURL=$CLOUD_URL -PsecurityToken=$SECURITY_TOKEN -PconfigFileLocation=config.json -PapkPath=app-debug.apk -PtestApkPath=app-debug-androidTest.apk -PjobName=${JOB_NAME} -PjobNumber=${BUILD_NUMBER}


    To utilize a local Android project, select Use Gradle Wrapper, select the Make gradlew executable checkbox, and provide the same Gradle tasks, as applicable.

  5. Run the job and get the Gradle output in the console logs.

Scenario 3 | Standalone mode with Gradle wrapper

This scenario is the same as Scenario 2 without the Jenkins Gradle plugin. Instead, you run an installed version of the Gradle wrapper.

Steps
  1. Perform Steps 1-6 as described in Scenario 2.
  2. Add another Execute shell build step to the Jenkins project.
  3. In the build step form, add the command to execute the Gradle wrapper. For example:

    /root/gradlew perfecto-android-inst -PcloudURL=$CLOUD_URL -PsecurityToken=$SECURITY_TOKEN -PconfigFileLocation=config.json -PapkPath=app-debug.apk -PtestApkPath=app-debug-androidTest.apk

    where: /root/gradlew is the full path to the Gradle wrapper executable.
    For more information on the relevant Gradle parameters, see Android configuration parameters for the Gradle Plugin.

  4. Run the job as in the previous scenario. The output is sent to the console.