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

Last updated: Nov 20, 2019 16:23

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 | Standalone mode with Gradle plugin

You run Gradle from Jenkins using the Jenkins Gradle plugin. Application, XCTest, XCUITest .ipa/.app files exist in the local file system and present in your configFile.json file, similar to this one.

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 iOS configuration parameters for the Gradle Plugin.

    perfecto-xctest 
    -PconfigFileLocation=configFile.json
    -PjobName=${JOB_NAME} -PjobNumber=${BUILD_NUMBER} -Pdebug=false -PcloudURL=${CLOUD_URL} 
    -PsecurityToken=${SECURITY_TOKEN}

  5. Run the job and get the Gradle output in the console logs. The following figure shows sample output.

Scenario 2 | Standalone mode with Gradle wrapper

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

Steps
  1. Perform steps 1-3 as described in Scenario 1.
  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-xctest 
    -PconfigFileLocation=configFile.json
    -PjobName=${JOB_NAME} -PjobNumber=${BUILD_NUMBER} -Pdebug=false -PcloudURL=${CLOUD_URL} 
    -PsecurityToken=${SECURITY_TOKEN}

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

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