所以我使用 Jenknis JUnit 解析器插件来解析测试结果。我有一份工作,只有一次测试,但总是失败。但是,JUnit 插件将作业标记为不稳定而不是失败。
有什么理由吗?
我尝试将健康报告放大系数设置为 1、0.1、0.0,但没有成功。似乎这就是我的工作被报告为不稳定而不是失败的原因。
如何让 JUnit 构建失败?
谢谢!
最佳答案
以下解决方法对我有用:
sh "test ${currentBuild.currentResult} != UNSTABLE"
我在 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"
}
}
}
关于即使测试失败,Jenkins JUnit 插件也会报告构建不稳定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55910431/