【发布时间】:2021-11-23 08:28:11
【问题描述】:
我的 CI/CD 管道有问题, 它已成功部署到 GCP 云运行,但在 Gitlab 仪表板上,状态为失败。
我尝试将图像替换为其他一些 docker 图像,但也失败了。
# File: .gitlab-ci.yml
image: google/cloud-sdk:alpine
deploy_int:
stage: deploy
environment: integration
only:
- integration # This pipeline stage will run on this branch alone
script:
- echo $GCP_SERVICE_KEY > gcloud-service-key.json # Google Cloud service accounts
- gcloud auth activate-service-account --key-file gcloud-service-key.json
- gcloud config set project $GCP_PROJECT_ID
- gcloud builds submit . --config=cloudbuild_int.yaml
# File: cloudbuild_int.yaml
steps:
# build the container image
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build','--build-arg','APP_ENV=int' , '-t', 'gcr.io/$PROJECT_ID/tpdropd-int-front', '.' ]
# push the container image
- name: 'gcr.io/cloud-builders/docker'
args: [ 'push', 'gcr.io/$PROJECT_ID/tpdropd-int-front']
# deploy to Cloud Run
- name: "gcr.io/cloud-builders/gcloud"
args: ['run', 'deploy', 'tpd-front', '--image', 'gcr.io/$PROJECT_ID/tpdropd-int-front', '--region', 'us-central1', '--platform', 'managed', '--allow-unauthenticated']
gitlab 构建输出:
ERROR: (gcloud.builds.submit)
The build is running, and logs are being written to the default logs bucket.
This tool can only stream logs if you are Viewer/Owner of the project and, if applicable, allowed by your VPC-SC security policy.
The default logs bucket is always outside any VPC-SC security perimeter.
If you want your logs saved inside your VPC-SC perimeter, use your own bucket.
See https://cloud.google.com/build/docs/securing-builds/store-manage-build-logs.
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1
【问题讨论】:
-
你能添加你的 GitLab CI/CD 作业输出吗?或者以其他方式解释您所说的“失败”是什么意思?
-
您的 Gitlab 步骤是否超时?关于失败的 gitlab 错误信息是什么?
-
我添加了 gtlab 输出
-
@AdamMarshall “失败”是 CI/CD 工作流的状态。
-
@MIkCode - 根据构建输出顶部的
ERROR: (gcloud.builds.submit),看起来 gcloud 命令正在返回错误状态,即使它实际上正在完成。如果命令的返回代码不是 0,GitLab 将假定作业失败 - 在这种情况下,退出代码为 1(根据构建输出中的最后一个注释)。您要么需要弄清楚提交代码返回 0 的原因,要么可以在命令末尾添加“|| true”以完全忽略错误。我强烈推荐第一个选项!
标签: google-cloud-platform gitlab