从失败的构建中存储工件

Storing Artifacts From a Failed 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,因此它成功退出,并且工件已上传。

我想:

编辑:

这是我的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