You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置AWS CodeBuild,未找到测试报告文件时不触发构建失败?

AWS CodeBuild 报告文件缺失时避免构建失败的配置方案

问题描述

我的AWS CodeBuild构建规范yml(版本2.0)的报告配置段如下:

reports:
  surefire-reports:
    files:
      - '**/target/surefire-reports/*.xml'
    discard-paths: false

当不存在报告文件时,CodeBuild构建任务会失败并抛出如下错误:

2022-11-11T13:19:32.9976751Z Error in UPLOAD_ARTIFACTS phase: [surefire-reports: [report files not found in build]]
2022-11-11T13:20:03.7200288Z ##[warning]The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-11-11T13:20:03.7249054Z ##[error]Build status: FAILED

需要配置为未找到报告文件时不触发构建失败。

解决方案

在报告配置节点下添加 fail-on-error: false 参数,该参数会让CodeBuild忽略报告文件缺失的问题,不会因此终止构建流程。

修改后的完整报告配置如下:

reports:
  surefire-reports:
    files:
      - '**/target/surefire-reports/*.xml'
    discard-paths: false
    fail-on-error: false

这个参数是CodeBuild 2.0版本构建规范的原生支持项,作用就是控制报告上传阶段的错误处理逻辑。添加后,即使没有匹配到指定的XML报告文件,构建流程也会正常完成,不会标记整个构建为失败状态。

内容的提问来源于stack exchange,提问作者tuk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 08:45:31