即使测试失败,Jenkins JUnit插件也将生成报告为不稳定

Jas*_*son 5 junit jenkins jenkins-plugins

因此,我正在使用Jenknis JUnit解析器插件来解析测试结果。我的工作只有一项测试,并且一直失败。但是,JUnit插件将作业标记为不稳定且未失败。

有什么原因吗?

我尝试将“运行状况”报告放大系数设置为1、0.1、0.0,但是没有运气。似乎这是我的工作被报告为不稳定且未失败的原因。

我怎样才能使JUnit生成失败?

谢谢!

Eri*_*sen 6

以下解决方法对我有用:

sh "test ${currentBuild.currentResult} != UNSTABLE"
Run Code Online (Sandbox Code Playgroud)

我在 junit 步骤之后添加了这个。所以最后你的管道看起来类似于:

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"
       }
    }
}
Run Code Online (Sandbox Code Playgroud)