Add reporting to Jenkins

This section guides you through adding Perfecto Smart Reporting to Jenkins.

Add a link to your report from within Jenkins

You can add a dynamically generated link to the report for a given Jenkins job by using the Groovy Postbuild Plugin.

The script should include the following code:

Copy
jobName = manager.build.getProject().getName()
buildNumber = manager.build.getNumber()

summary = manager.createSummary("graph.gif")
summary.appendText("<a href=\"https://<CQL_NAME>.app.perfectomobile.com/library?jobName[0]=${jobName}&jobNumber[0]=${buildNumber}\">Perfecto Test Report</a>", false)

See the details of the reporting server.

Group tests by job and build in the Report Library

To view tests grouped by continuous integration system job and build in the Report Library, you need to provide the job name and build number into reporting as system variables. This enables you to group your test executions in reporting first by job name and then by build number, providing you a complete overview of the build quality.

Supply Maven or Ivy parameters

Watch this short video to see how to add the Jenkins Job Name and Build Number parameters to your script. Detailed steps follow.

To supply Maven or Ivy parameters:

If you are running your tests using Maven or Ivy, add the following JVM parameters and (optionally) the Report-tags parameter:

Copy
-Dreportium-job-name=${JOB_NAME} -Dreportium-job-number=${BUILD_NUMBER} -Dreportium-job-branch=${GIT_BRANCH} -Dreportium-tags=${myTag}

You need to supply the myTag value. Jenkins automatically supplies the JOB_NAME,  BUILD_NUMBER, and GIT_BRANCH.

To add CustomField pairs, use the following format:

Copy
-DReportiumCustomFields=customField1=value1,customField2=value2

Set up Slack notifications

Using the Slack plugin for Jenkins, you can configure Jenkins to send you a notification when the tests complete and include the link to the report for easy access. Watch this short video to see how it works. Detailed steps follow.

To set up Smart Reporting notifications in your Jenkins Slack channel:

  1. Go to the Post-build Actions section of the project configuration in Jenkins. 
  2. In the Slack Notifications sub-section, do the following:
    1. Find and select the Include Custom Message checkbox. 
      Note: You may need to click Advanced to access this field.
    2. In the Custom Message field, add the following:

      View your Perfecto report at:

      https://<CQL_NAME>.reporting.perfectomobile.com/library?jobName[0]=${JOB_NAME}&jobNumber[0]=${BUILD_NUMBER}&tags[0]=${myTag}

      where:

      <CQL_NAME> is the prefix of your Perfecto Lab. For example, if you access the Perfecto Lab at https://demo.perfectomobile.com, then <CQL_NAME>=demo.