Last updated: Oct 07, 2019 12:44
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.
Scenario 1 | Android Studio
An Android Studio (AS) project folder is hosted in a Git Repository that is accessible to Jenkins. The AS project is already configured to work with the Gradle plugin, meaning the
build.gradle files and
config.json file are defined properly, as described in the Use the Gradle plugin in Android Studio Project. The Gradle wrapper is included in the AS project.
- Create a new Jenkins Job.
- Add the Source Code Management information for the Git repository location of the project.
- Add the build step using the Gradle wrapper application from the AS project to activate the plugin.
- 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. For Android, application debug and Espresso-test apk files exist in the local file system. For iOS, application, XCTest, XCUITest ipa files exist in the local file system.
- Create a new parameterized Jenkins job
The Job uses the Perfecto Lab URL, Security token, "build.gradle" file, and configuration file as parameters to the job.
- Add a String parameter with your Perfecto Lab URL as default
- Add a String parameter with your security token as default
To make the build.gradle file and plugin configuration file more dynamic, add their content as Multi-line String parameters and then create the files during the job build
"build.gradle" example (used in the above dialog):
Configuration file example (dialog above presents a parallel Android example):
- (For Android) Add the apk and test apk files as File parameters with the location ./app-debug.apk and ./app-debug-androidTest.apk,
(For iOS) Add the application ipa and UI test ipa runner files as File parameters with the location ./app.ipa and ./app-tests-runner.ipa,
these files may also be passed from a different job or download them from a remote repository.
- In the build section we create the "build.gradle" and "config.json" files according to the parameters we've received above in two "Execute shell" build steps
Add an "Invoke gradle script" where we run the plugin task with the command. Add also the Job name and Build number in the command these allow you to filter the specific tests in the reports.
Run the job and get the Gradle output in the console logs
Scenario 3 | Standalone mode with Gradle wrapper
Same as Scenario 2 but 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.
Add the command to execute the Gradle wrapper, for example:
/root/gradlewis the full path to the gradle wrapper executable.
Run the job as in the previous scenario. The output is sent to the console.