Integrating Cypress with Jenkins

Viewed 1849

Here is my configuration in Jenkins, I made a new test pipeline. I am not sure the configuration is correct, because the build keeps failing when it hits "Cypress Run"

Jenkins Configuration:

 node(label: 'FAKE_BUILDER') {
    stage('Checkout Git Repo') {
        git credentialsId: '12345',
        branch: 'master',
        url: 'https://github.com/fake'
    }
    stage('install') {
        sh label: 'NPM install', script: 'npm install'
        sh label: 'NPM start', script: 'npm start'
        sh label: 'Cypress Run', script: 'npx cypress run'
    }
}

In my project, Jenkins file:

pipeline {
    notifySparkRoomId = "Y2EK"
    buildVersion = this.env.BUILD_NUMBER
    numToKeep = this.isMasterBranch() ? 50 : 3
    services = []

    builder = "FAKE_BUILDER"

    build = {
        this.sh "./bin/install.sh"
        this.sh "./bin/cypresstestscript.sh"

        if (this.isMasterBranch() || this.isHotfixBranch()) {
          this.sh "./bin/run.sh ./bin/build.sh"
          this.sh "tar -czf fake.tar.gz -C dist ."
          this.archiveArtifacts artifacts: "fake.tar.gz", allowEmptyArchive: true
      }
    }

    junitPattern = null
    spotbugsOpts = null

    deployTo = this.isMasterBranch() || this.isHotfixBranch() ? ['integration', 'production'] : []

    integration.deployMode = this.isMasterBranch() ? 'deploy' : 'input'
    integration.postDeployTests = []
    integration.runConsumerTests = false
}

1 Answers

Apparently, xvfb is not installed on your Jenkins server.

Install it via:

apt-get update && apt-get -y install xvfb
Related