【问题标题】:Azure devops pipeline job shows success even though the Maven task is failed即使 Maven 任务失败,Azure devops 管道作业也显示成功
【发布时间】:2021-01-28 08:44:22
【问题描述】:

即使目标任务失败,我也会在 Maven 任务日志中看到“构建成功”。如果任务有以下错误,如何使工作失败?谢谢。

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

【问题讨论】:

    标签: azure maven azure-devops task pipeline


    【解决方案1】:

    您项目的测试方法失败不是“Standard Error”。它只是您项目的测试方法的结果报告,不会写入 StandardError 流。所以,失败并不影响任务运行的最终状态。

    如果您希望作业在测试失败时失败,作为一种变通方法,您可以尝试设置一个脚本来检查测试结果,并编写一个'Standard Error'(例如Exit 1) 到 StandardError 流,如果有任何测试失败。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-08-06
      • 2012-09-13
      • 2021-05-10
      • 2020-11-09
      • 2022-07-15
      • 1970-01-01
      • 2023-04-08
      • 1970-01-01
      相关资源
      最近更新 更多