Jenkins with Espresso
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.
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.

-
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. -
Add a string parameter with your Perfecto Lab URL as the default value.
-
Add a string parameter with your security token as the default value.
-
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.
Copyperfecto-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}
-
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.

- Perform Steps 1-6 as described in Scenario 2.
- Add another Execute shell build step to the Jenkins project.
-
In the build step form, add the command to execute the Gradle wrapper. For example:
Copy/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.
-
Run the job as in the previous scenario. The output is sent to the console.