如何使Jenkins在Maven 2构建中实现--fail-fast? [英] How to get Jenkins to --fail-fast on Maven 2 builds?
问题描述
我正在尝试使用Jenkins构建多模块Maven项目.
I am trying to build a multi-module Maven project using Jenkins.
当我使用相同环境(variables/settings.xml/user)在命令行上构建与Jenkins相同的项目时,测试失败会导致构建立即失败:
When I build the same project on the command-line using the same environment (variables/settings.xml/user) as Jenkins does, test failures cause the build to fail immediately:
Failed tests:
testSomething(com.package_name.TestSomethingOrTheOther)
Tests run: .., Failures: 1, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.
...
# Build fails immediately
在 Jenkins 中构建时的位置:
Failed tests:
testSomething(com.package_name.TestSomethingOrTheOther)
Tests run: .., Failures: 1, Errors: 0, Skipped: 0
[ERROR] There are test failures.
...
# Build continues to other modules
...
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] parent ................................................ SUCCESS [.....s]
[INFO] module-that-failed .................................... SUCCESS [.....s]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
该版本说明所有模块和父级均成功 -ful,而实际上,这些应该是失败的.
The build states that all modules and parent are SUCCESS-ful, when in reality, these should be failures.
我如何让Jenkins像maven在命令行中那样在Maven构建中强制执行故障快速?
谢谢.
推荐答案
Jenkins默认忽略测试失败,然后将构建标记为不稳定(如果有的话).
Jenkins ignores test failures by default, and then marks the build as unstable if they were any.
用于控制的参数为:testFailureIgnore(请参见 surefire插件文档 )
The parameter that controls that is: testFailureIgnore (see surefire plugin doc)
我从未尝试过,但是我会尝试在詹金斯工作配置上覆盖该设置:
I've never tried that, but I would attempt to override that setting on the jenkins job configuration:
-Dmaven.test.failure.ignore = false
-Dmaven.test.failure.ignore=false
这篇关于如何使Jenkins在Maven 2构建中实现--fail-fast?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!