即使测试失败,Jenkins JUnit 插件也会报告构建不稳定

标签 jenkins junit jenkins-plugins

所以我使用 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/

相关文章:

git - Jenkins 间歇性 git 连接错误

Jenkins - 在同一 View 中显示多个多分支管道的所有主分支

java - Jenkins Git 客户端插件无法执行 FetchCommand

angular - Angular 2/Typescript 项目的持续集成

jenkins - Jenkins 中轻量级结帐和浅层克隆之间的区别

ant - 使用依赖于环境变量的代码进行单元测试

jenkins - 如何从 jenkins 作业构建文件夹下载文件

java - [Easy|Power]Mock : make constructor. newInstance(...) 抛出异常?

junit - Hamcrest - Matchers.hasProperty : how to check if a List of objects contains an object with a concrete value

git - Jenkins GIT部署后如何设置权限