How to get Jenkins to --fail-fast on Maven 2 builds?

别等时光非礼了梦想. 提交于 2019-12-21 20:33:11

问题


I am trying to build a multi-module Maven project using 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

Where-as when building in 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] ------------------------------------------------------------------------

The build states that all modules and parent are SUCCESS-ful, when in reality, these should be failures.

How do I get Jenkins to enforce fail-fast in maven builds as maven does in the command-line?

Thanks in advance.


回答1:


Jenkins ignores test failures by default, and then marks the build as unstable if they were any.

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




回答2:


You can specify MAVEN_OPTS if you click on Advanced button in the Build section.



来源:https://stackoverflow.com/questions/10418931/how-to-get-jenkins-to-fail-fast-on-maven-2-builds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!