google-cloud-build - 从失败的构建中存储工件

标签 google-cloud-build

我正在我的 Cloud Build 步骤之一中运行一些屏幕差异测试。测试生成我想在构建后查看的 png 文件,但它似乎会在成功构建时上传工件。

如果我的测试失败,进程将以非零代码退出,从而导致此错误:

ERROR: build step 0 "gcr.io/k8s-skaffold/skaffold" failed: step exited with non-zero status: 1

这进一步导致了另一个错误


ERROR: (gcloud.builds.submit) build a22d1ab5-c996-49fe-a782-a74481ad5c2a completed with status "FAILURE"

并且没有工件被上传。

我添加了|| true 在我的测试之后,所以它成功退出,并且工件被上传。

我想:

  • A) 确认此行为是预期的
  • B) 即使步骤失败,也知道是否有上传工件的方法

编辑:

这是我的cloudbuild.yaml


options:
 machineType: 'N1_HIGHCPU_32'

timeout: 3000s

steps:

- name: 'gcr.io/k8s-skaffold/skaffold'
  env:
  - 'CLOUD_BUILD=1'
  entrypoint: bash
  args:
  - -x  # print commands as they are being executed
  - -c  # run the following command...
  - build/test/smoke/smoke-test.sh


artifacts:
  objects:
    location: 'gs://cloudbuild-artifacts/$BUILD_ID'
    paths: [
      '/workspace/build/test/cypress/screenshots/*.png'
    ]

最佳答案

如果构建步骤失败,Google Cloud Build 不允许我们上传工件(或运行某些步骤)。这是预期的行为。

已在 Public Issue Tracker 中创建了一个功能请求允许我们运行一些步骤,即使构建已经完成或失败。请随时为其加注星标,以获取有关此问题的所有相关更新。

目前的解决方法是您提到的使用 ||测试后为真或使用 || Github issue 中提到的 exit 0 .

关于google-cloud-build - 从失败的构建中存储工件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61487234/

相关文章:

google-cloud-platform - 在 Google Cloud Build 上部署 NodeJs 应用程序的问题

docker - COPY失败:未指定源文件

docker - 谷歌云构建中两个容器之间的通信

google-cloud-platform - Google Cloud 在另一个路径中构建挂载卷

google-cloud-build - PROJECT_ID env 和 Secret Manager 访问权限

google-cloud-run - 云构建到云运行步骤中的 secret

python - 如何使用 python-cloudbuild 运行构建触发器

git - Google Cloud Build 无法运行 NX 影响 :apps because it cannot reference the master~1 commit

git - cloudbuild.yaml 包含不同的云构建器配置

google-cloud-build - 如何防止云构建并行运行构建?