cloudbuild.yaml 上的错误:(gcloud.builds.submit) 将 cloudbuild.yaml 解释为构建配置:'list' 对象没有属性 'items'
Error on cloudbuild.yaml : (gcloud.builds.submit) interpreting cloudbuild.yaml as build config: 'list' object has no attribute 'items'
这是我的 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
ERROR: (gcloud.builds.submit) interpreting ./cloudRun/cloudbuild.yaml as build config: 'list' object has no attribute 'items'
刚刚发现问题所在:
substitutions
不是 ARRAY,而是 OBJECT:
所以这是不正确的:
substitutions:
- "_SERVER_ENV=TEST"
但这是正确的:
substitutions:
_SERVER_ENV: "TEST"
这是我的 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
ERROR: (gcloud.builds.submit) interpreting ./cloudRun/cloudbuild.yaml as build config: 'list' object has no attribute 'items'
刚刚发现问题所在:
substitutions
不是 ARRAY,而是 OBJECT:
所以这是不正确的:
substitutions:
- "_SERVER_ENV=TEST"
但这是正确的:
substitutions:
_SERVER_ENV: "TEST"