[英]Google Cloud Build - Summary status shows FAILURE, all steps succeded
我已經設置了一個 Google Cloud Build 管道,它將從 Dockerfile 構建 docker 映像,測試映像並將映像推送到 Google Container Registry。
在運行管道時,我注意到所有定義的步驟都以SUCCESS
狀態通過,但構建摘要本身返回FAILURE
狀態,即使我可以看到正在生成到 Google Container Registry 中的圖像。
我使用以下命令來構建圖像
gcloud builds submit --config cloudbuild.yml --gcs-log-dir 'gs://<bucket>' .
以下是返回的錯誤消息:
ERROR: (gcloud.builds.submit) build www-xxxx-yyyy-zzzz completed with status "FAILURE"
🚨 Error: The command exited with status 1
如果所有步驟都標記為SUCCESS
, gcloud builds submit
命令是否有任何理由以上述代碼1
退出?
下面是從gcloud builds describe
命令獲取的一些過濾日志數據,用於該特定構建。
steps:
- args:
- build
- -t
- <host>/<project/<image>:<tag>
- .
name: gcr.io/cloud-builders/docker
status: SUCCESS
- args:
- test
- --image
- <host>/<project/<image>:<tag>
- --config
- test_config.yml
- -o
- json
name: gcr.io/gcp-runtimes/container-structure-test
status: SUCCESS
以下是 Google Cloud Build 設置:
# cloudbuild.yml
steps:
# Build the image
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', '<host>/<project/<image>:<tag>', '.' ]
# Test the image
- name: 'gcr.io/gcp-runtimes/container-structure-test'
args: [
'test',
'--image',
'<host>/<project/<image>:<tag>',
'--config',
'test_config.yml',
'-o',
'json'
]
# Push the image
images: [ '<host>/<project/<image>:<tag>' ]
在 Google Cloud 支持團隊的幫助下,我終於解決了這個問題。
他們發現403 Permission Denied
錯誤,因為 Cloud Build 容器試圖訪問 Google Cloud Storage 以刪除存儲在存儲桶中的某個日志 object,此錯誤消息在 Cloud Build 的后端系統中找到,用戶/客戶無權訪問. 403 Permission Denied
錯誤是應用到存儲桶的 object 保留策略的結果。
就我而言,我已將保留策略替換為生命周期策略來解決此問題,並且效果很好。 我們這樣做是因為我們認為控制 Cloud Build 日志大小是我們的主要目標,並且為了防止對日志文件的任何意外刪除/修改,我們最終設置了對日志存儲桶中資源的只讀訪問權限,除了Cloud Build 使用的服務帳號。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.