Making the jenkins build failure if cypress TC failure

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

    stage('Run E2E tests') {
     steps {
          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 \
            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

I’m going to recommend the ssh-agent plugin for this block - SSH Agent
It handles all the temp adding and cleanup and stuff.

Warnings Next Generation is pretty much what you want, you can set thresholds, and it can graph changes and stuff. You’ll want to export a junit (or other parseable format) file to import to warnings, but I recommend that

Thanks for the suggestions

Not sure Warnings Next Generation will help as our sample cypress mocha report will show the result in this way " 13 of 13 failed (100%) " . we need to parse this result and make the build failure if any of the TC is failed.

According to Warnings Next Generation

“If your tool is not yet supported by the warnings plugin you can either define a new Groovy based parser in the user interface or provide a parser within a new small plug-in. If the parser is useful for other teams as well please share it and provide pull requests for the Warnings Next Generation Plug-in and the Analysis Parsers Library.”

The Groovy based parser could work for what you want.

Ok , you mean i can add one more stage like below to parse the console output

stage('CheckLog') {
      steps {
        if (manager.logContains('.*myTestString.*')) {
          error("Build failed because of this and that..")    

@slide_o_mix i am not able use the if condition in the steps , getting below error

WorkflowScript: 50: Expected a step @ line 50, column 17.

Are you using declarative pipeline? If so, you’ll need to wrap the if with a script {} block.