简体   繁体   English

Azure devops 管道作业显示成功,即使 Maven 任务失败

[英]Azure devops pipeline job shows success even though the Maven task is failed

I'm getting "Build Success" in the log of Maven task even though the goal task is failure.即使目标任务失败,我也在 Maven 任务的日志中得到“构建成功”。 How to make the job a failure if the task has errors as below?如果任务有以下错误,如何使工作失败? Thanks.谢谢。

Yaml file: Yaml文件:

    - task: Maven@3
  inputs:
    mavenPomFile: 'pom.xml'
    mavenOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    publishJUnitResults: true
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    goals: 'integration-test -DskipIntegrationTests=false -Dmaven.test.failure.ignore=false'

Error as below:错误如下:

[Error] Failures:
[Error] <Filename> errror details
[INFO]
[ERROR] Tests run:2, Failures:2, Errors:0, Skipped:0
[INFO]
[INFO]----------------------------------------------
[INFO] BUILD SUCCESS
[INFO]----------------------------------------------

The failure of the test methods for your project is not the ' Standard Error '.您项目的测试方法的失败不是“ Standard Error ”。 It just a result report of the test methods for your project, and will not be written to the StandardError stream.它只是您项目的测试方法的结果报告,不会写入StandardError stream。 So, the failure does not affect the final status of the task run.所以,失败不会影响任务运行的最终状态。

If you want the job fails when the tests fail, as a workaround, you can try to set up a script to check the test result, and write a ' Standard Error ' (eg Exit 1 ) to the StandardError stream if there is any test fails.如果您希望作业在测试失败时失败,作为一种解决方法,您可以尝试设置一个脚本来检查测试结果,如果有任何测试,则将“ Standard Error ”(例如Exit 1 )写入StandardError stream失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM