Making the jenkins build failure if cypress TC failure

Viewed 28

Currently , my cypress testes are runnning in docker container on one stage


    stage('Run E2E tests') {
     steps {
        withCredentials([
          sshUserPrivateKey(credentialsId: '*********', keyFileVariable: 'SSH_KEY_FILE', usernameVariable: 'SSH_USER')
         ]) {
        sh """
            eval `ssh-agent -s`
            ssh-add ${SSH_KEY_FILE}
            ~/earthly \
              --no-cache \
              --config=.earthly/config.yaml \
              +e2e
            eval `ssh-agent -k`
          """
        }
      } 
    }

And publishing the test report to via publishHTML.

post {
    always {
      echo "-- Archive report artifacts"
      archiveArtifacts artifacts: 'results', allowEmptyArchive: 'true'
      echo "-- Publish HTLM test result report"
      publishHTML (target: [
            allowMissing: false,
            alwaysLinkToLastBuild: false,
            keepAll: true,
            reportDir: 'results/html/',
            reportFiles: 'mochawesome-bundle.html',
            reportName: "Test Result Report"
          ])
    }
  }

But i need to make the build failure if any of the TC failure in the cypress mocha report

what can be the solution for this..?

Thanks in advance

0 Answers
Related