cloudbuild.yaml 上的错误:(gcloud.builds.submit)将 cloudbuild.yaml 解释为构建配置:“列表”对象没有属性“项目”
Posted
技术标签:
【中文标题】cloudbuild.yaml 上的错误:(gcloud.builds.submit)将 cloudbuild.yaml 解释为构建配置:“列表”对象没有属性“项目”【英文标题】:Error on cloudbuild.yaml : (gcloud.builds.submit) interpreting cloudbuild.yaml as build config: 'list' object has no attribute 'items' 【发布时间】:2021-03-21 20:07:06 【问题描述】:这是我的cloudbuild.yaml
文件:
steps:
# BUILD IMAGE
- name: "gcr.io/cloud-builders/docker"
args:
- "build"
- "--build-arg"
- "PROJECT_ID=$PROJECT_ID"
- "--build-arg"
- "SERVER_ENV=$_SERVER_ENV"
- "--tag"
- "gcr.io/$PROJECT_ID/my-image:$TAG_NAME"
- "."
env:
- "PROJECT_ID=$PROJECT_ID"
timeout: 180s
# PUSH IMAGE TO REGISTRY
- name: "gcr.io/cloud-builders/docker"
args:
- "push"
- "gcr.io/$PROJECT_ID/my-image:$TAG_NAME"
timeout: 180s
# DEPLOY CONTAINER WITH GCLOUD
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
entrypoint: gcloud
args:
- "run"
- "deploy"
- "my-service"
- "--image=gcr.io/$PROJECT_ID/my-image:$TAG_NAME"
- "--platform=managed"
- "--region=us-central1"
- "--min-instances=1"
- "--max-instances=3"
- "--port=8080"
timeout: 180s
images:
- "gcr.io/$PROJECT_ID/my-image:$TAG_NAME"
substitutions:
- "_SERVER_ENV=TEST"
这个文件有什么问题吗?
这是我在运行以下命令时遇到的错误:
gcloud builds submit ./cloudRun \
--config=./cloudRun/cloudbuild.yaml \
--substitutions=_SERVER_ENV=TEST,TAG_NAME=MY_TAG \
--project=MY_PROJECT_ID
错误:(gcloud.builds.submit) 将 ./cloudRun/cloudbuild.yaml 解释为 build config: 'list' object has no attribute 'items'
【问题讨论】:
【参考方案1】:刚刚发现问题所在:
substitutions
不是ARRAY,而是OBJECT:
所以这是不正确的:
substitutions:
- "_SERVER_ENV=TEST"
但这是正确的:
substitutions:
_SERVER_ENV: "TEST"
【讨论】:
以上是关于cloudbuild.yaml 上的错误:(gcloud.builds.submit)将 cloudbuild.yaml 解释为构建配置:“列表”对象没有属性“项目”的主要内容,如果未能解决你的问题,请参考以下文章
Google Cloud Build 不会替换 cloudbuild.yaml 的机密部分中的值
有啥方法可以从 docker hub 提取图像并使用 cloudbuild.yaml 部署到云运行