Gitlab 管道失败,即使部署发生在 GCP 上
Gitlab pipeline fails, even though deployment happened on GCP
我刚刚在 Gitlab 上创建了我的第一个 CI/CD 管道,它为 Next.js 应用程序创建了一个 docker 容器,并将其部署在 Google 云端 运行.
我的cloudbuild.yaml:
# File: cloudbuild.yaml
steps:
# build the container image
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/inook-web', '.' ]
# push the container image
- name: 'gcr.io/cloud-builders/docker'
args: [ 'push', 'gcr.io/$PROJECT_ID/inook-web']
# deploy to Cloud Run
- name: "gcr.io/cloud-builders/gcloud"
args: ['run', 'deploy', 'inook-web', '--image', 'gcr.io/$PROJECT_ID/inook-web', '--region', 'europe-west1', '--platform', 'managed', '--allow-unauthenticated']
我的.gitlab-ci.yml:
# File: .gitlab-ci.yml
image: docker:latest
stages: # List of stages for jobs, and their order of execution
- deploy-test
- deploy-prod
deploy-test:
stage: deploy-test
image: google/cloud-sdk
services:
- docker:dind
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.yaml
我在 CI/CD 管道中收到以下错误消息:
https://ibb.co/ZXLWrj1
然而,部署实际上在 GCP 上成功了:https://ibb.co/ZJjtXzG
知道我可以做些什么来修复管道错误吗?
对我有用的是为 gcloud 构建提交添加一个自定义存储桶以将日志推送到。感谢@slauth 为我指明了正确的方向。
更新命令:
gcloud builds submit . --config=cloudbuild.yaml --gcs-log-dir=gs://inook_test_logs
如果你在命令末尾添加一个桶,那么它就有效。
gcloud builds submit . --config=cloudbuild.yaml --gcs-log-dir=gs://my_bucket_name_on_gcp
记得在 GCP 上创建一个 bucket :D
我刚刚在 Gitlab 上创建了我的第一个 CI/CD 管道,它为 Next.js 应用程序创建了一个 docker 容器,并将其部署在 Google 云端 运行.
我的cloudbuild.yaml:
# File: cloudbuild.yaml
steps:
# build the container image
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/inook-web', '.' ]
# push the container image
- name: 'gcr.io/cloud-builders/docker'
args: [ 'push', 'gcr.io/$PROJECT_ID/inook-web']
# deploy to Cloud Run
- name: "gcr.io/cloud-builders/gcloud"
args: ['run', 'deploy', 'inook-web', '--image', 'gcr.io/$PROJECT_ID/inook-web', '--region', 'europe-west1', '--platform', 'managed', '--allow-unauthenticated']
我的.gitlab-ci.yml:
# File: .gitlab-ci.yml
image: docker:latest
stages: # List of stages for jobs, and their order of execution
- deploy-test
- deploy-prod
deploy-test:
stage: deploy-test
image: google/cloud-sdk
services:
- docker:dind
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.yaml
我在 CI/CD 管道中收到以下错误消息: https://ibb.co/ZXLWrj1
然而,部署实际上在 GCP 上成功了:https://ibb.co/ZJjtXzG
知道我可以做些什么来修复管道错误吗?
对我有用的是为 gcloud 构建提交添加一个自定义存储桶以将日志推送到。感谢@slauth 为我指明了正确的方向。
更新命令:
gcloud builds submit . --config=cloudbuild.yaml --gcs-log-dir=gs://inook_test_logs
如果你在命令末尾添加一个桶,那么它就有效。
gcloud builds submit . --config=cloudbuild.yaml --gcs-log-dir=gs://my_bucket_name_on_gcp
记得在 GCP 上创建一个 bucket :D