Jenkins with Cypress

You can use the NodeJS plugin as part of a Jenkins CI job. Learn how to integrate your Cypress framework with Jenkins, including the option to utilize another parameterization while triggering.

Important: This document includes references to third-party products, Jenkins and Cypress. The user interface and usage of third-party products are subject to change without notice. For the latest published information about Jenkins, see https://www.jenkins.io/doc/. For the latest published information about Cypress, see https://docs.cypress.io/.

Prerequisites

To integrate Cypress with Jenkins, make sure that:

  • The Perfecto Cypress SDK has been configured with the cloud name and security token in the perfecto-config.json file.

    For details, see the initial setup instructions for Cypress.

  • In the package.json file, edit, add, or modify the scripts section according to your requirements:

    Copy
    {
      "name": "cypressdemo",
      "version": "1.0.0",
      "description": "Perfecto Cypress Jenkins demo",
      "main": "index.js",
      "scripts": {
         "test": "./node_modules/.bin/cypress run --config pageLoadTimeout=60000",
         "cy:run": "npm run test"
      },
      "author": "rk@perforce.com",
      license": "ISC",
      "devDependencies": {
         "cypress": "^7.5.0",
         "perfecto-cypress-reporter": "0.0.12",
         "perfecto-cypress-sdk": "0.0.52"
      }
    }

Step-by-step instructions

Follow the steps in this section to integrate an existing Perfecto-Cypress SDK project with Jenkins.

To integrate an existing Perfecto-Cypress SDK project with Jenkins:

  1. In Jenkins, open the Plugin Manager. Then download and configure NodeJS.

  2. Open the Configuration Manager and configure and point to the correct shell or bash executable.

  3. Open the Global Tool Configuration and configure NodeJS to the latest version.

  4. Create a new Jenkins job.

  5. Add a build step, as follows. You can run trigger job configuration by using the following commands locally or in the Perfecto cloud. 

    • For local triggering:

      Copy
      npm run cy:run
    • For Perfecto configuration and triggering report generation:

      Copy
      npx perfecto-cypress run --config=./perfecto-config.json

      You can use:

  6. Run the job and get the Cypress output in the console logs.
  7. In the Perfecto UI, open the individual report.
  8. Download the Cypress logs by clicking the download option .

For additional help, contact Perfecto Support.