0

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

Deepak
  • 11
  • 3
  • Where are you trying to report the failure to? What is currently being reported? – agoff Sep 13 '22 at 13:42
  • @agoff : Currently the Build is getting success , irrespective of TC success/failure. i would like to make the build as red[failure] if one of the TC failure – Deepak Sep 13 '22 at 14:10
  • I am trying add one more stage to validate the console output from build stage('CheckLog') { steps { if (manager.logContains('.*myTestString.*')) { error("Build failed because of this and that..") } } will this approach will work..? – Deepak Sep 14 '22 at 10:16
  • So you just want to mark the Jenkins build as failed if any test cases fail? – agoff Sep 14 '22 at 13:43
  • Yes , that is my plan @agoff – Deepak Sep 14 '22 at 13:45
  • Is there any possibility of you also generating a `junit` result? Jenkins most easily accepts JUnit XML files as test results, so if you can generate that, and then report it to Jenkins, it should already mark the build as Unstable. – agoff Sep 14 '22 at 13:54
  • I have to check , that option. current cypress is throwing in different format – Deepak Sep 14 '22 at 13:59
  • Cypress has a `junit` reporter built in, but I know that generating multiple reports can be tricky. – agoff Sep 14 '22 at 14:02
  • @agoff : looks like i dont have other choice , adding junit based report , will update if it is success. Appreciate the responses – Deepak Sep 15 '22 at 05:41

0 Answers0