[英]What causes Google gcloud error message "ERROR: (gcloud) Invalid choice: 'gcloud'" and how to resolve this?
I am trying to deploy a cloud function in GCP using CI-CD
process.我正在尝试使用
CI-CD
流程在 GCP 中部署云 function。 I have written a yaml file.我写了一个yaml的文件。 Below is my code: cloudbuild.yaml
下面是我的代码:cloudbuild.yaml
# Deploy Cloud Function
- name: "gcr.io/cloud-builders/gcloud"
id: deploy
dir: "/workspace/API/audit_from_storage"
args:
[
'gcloud', 'functions', 'deploy', 'audit_deployed',
'--set-env-vars', 'BASEURL=${_CP_BASE_URL},BUCKETNAME=${_BUCKETNAME},FUNCTION=${_FUNCTION}',
'--region=us-central1',
'--source=.',
'--trigger-resource=${_BUCKETNAME}',
'--trigger-event=google.storage.object.finalize',
'--runtime=nodejs10',
'--entry-point=collectAudit',
'--service-account=${_SERVICE_ACCOUNT}',
]
Below are the logs:以下是日志:
Finished Step #0 - "installing_npm"
Starting Step #1 - "deploy"
Step #1 - "deploy": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #1 - "deploy": ERROR: (gcloud) Invalid choice: 'gcloud'.
Step #1 - "deploy": Maybe you meant:
Step #1 - "deploy": gcloud functions deploy
Step #1 - "deploy": gcloud run deploy
Step #1 - "deploy": gcloud deployment-manager deployments cancel-preview
Step #1 - "deploy": gcloud deployment-manager deployments create
Step #1 - "deploy": gcloud deployment-manager deployments delete
Step #1 - "deploy": gcloud deployment-manager deployments describe
Step #1 - "deploy": gcloud deployment-manager deployments list
Step #1 - "deploy": gcloud deployment-manager deployments stop
Step #1 - "deploy": gcloud deployment-manager deployments update
Step #1 - "deploy":
Step #1 - "deploy": To search the help text of gcloud commands, run:
Step #1 - "deploy": gcloud help -- SEARCH_TERMS
Finished Step #1 - "deploy"
ERROR
ERROR: build step 1 "gcr.io/cloud-builders/gcloud" failed: step exited with non-zero status: 2
Please help me resolve this.请帮我解决这个问题。 Below is the script after removing the
gcloud
argument from the array list:下面是从数组列表中删除
gcloud
参数后的脚本:
Edit:
# Deploy Cloud Function
- name: "gcr.io/cloud-builders/gcloud"
id: deploy
dir: "/workspace/API/audit_from_storage"
args:
[
'functions', 'deploy', 'audit_from_storage',
'--set-env-vars', 'BASEURL=${_CP_BASE_URL},BUCKETNAME=${_BUCKETNAME},FUNCTION=${_FUNCTION}',
'--region=us-central1',
'--source=.',
'--trigger-resource=${_BUCKETNAME}',
'--trigger-event=google.storage.object.archive',
'--runtime=nodejs10',
'--entry-point=collectAudit',
'--service-account=${_SERVICE_ACCOUNT}',
]
Below are the logs:以下是日志:
Starting Step #1 - "deploy"
Step #1 - "deploy": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #1 - "deploy": ERROR: (gcloud.functions.deploy) could not parse resource []
Finished Step #1 - "deploy"
ERROR
ERROR: build step 1 "gcr.io/cloud-builders/gcloud" failed: step exited with non-zero status: 1
Thanks Pritish谢谢英国人
You don't need gcloud
in the args array;您不需要 args 数组中的
gcloud
; it's the entrypoint for the container.它是容器的入口点。
So, just:所以就:
args: ["functions","deploy",...]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.