docker - Gitlab 管道失败,即使部署发生在 GCP 上
问题描述
我刚刚在 Gitlab 上创建了我的第一个 CI/CD 管道,它为 Next.js 应用程序创建了一个 docker 容器,并将其部署在 Google Cloud Run 上。
我的 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
推荐阅读
- android-studio - 为什么我的 AVD 管理器中的“创建虚拟设备”按钮被禁用?
- laravel - 创建角色权限时无法更改状态如何单次更改状态
- json - 我想在邮递员中编写测试用例来验证下面的测试用例
- angular - 我已经通过 useFactory 获得了环境,那么如何将每个环境的值传递给 AppModule?
- javascript - 在之前没有创建任何数据的情况下,按下对 Firebase 数据库的“删除功能”引用的按钮时出错
- mysql - 为什么 IF(COUNT(id)%2 = 0 ,IF(id % 2 = 0, id - 1, id + 1),IF(id < MAX(id),IF(id % 2 = 0, id - 1 , id + 1) , id)) 不工作?
- python - Python Kivy 在标签中使用彩色表情符号
- orbeon - 如何在 orbeon 表单中选择多个复选框时隐藏或显示控件
- html - CSS iPhone 不能正确渲染
- .net - 有没有一种有效的方法在 Powershell/.net 中获取“Get-ComputerInfo 数据”