Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins JUnit Plugin reports a build as unstable even if test fails

So I am using the Jenknis JUnit parser plugin to parse the test results. I have a job which has just one test and it fails all the time. However, the JUnit plugin marks the job as unstable and not failed.

Any reasons why?

I have tried to set the Health report amplification factor to 1, 0.1, 0.0 but no luck. Seems like somehow this is the reason why my job is reported as Unstable and not Failed.

How can I get the JUnit to fail the build?

Thanks!

like image 701
Jason Avatar asked Apr 29 '19 20:04

Jason


1 Answers

The following workaround worked for me:

sh "test ${currentBuild.currentResult} != UNSTABLE"

I added this right after the junit step. So in the end your pipeline looks similar to this:

stage('test') {
    steps {
        sh "mvn -Dmaven.test.failure.ignore=true -DtestFailureIgnore=true test"
    }
    post {
       success {
           junit '**/target/surefire-reports/**/*.xml'
           sh "test ${currentBuild.currentResult} != UNSTABLE"
       }
    }
}
like image 119
Erik Nellessen Avatar answered Oct 04 '22 10:10

Erik Nellessen