简体   繁体   中英

How to deploy a function on GCP with Cloud Build?

I have created a Cloud Function called pupetter-e2e with a trigger on changes to a bucket storage, called homepage. I want to deploy updates to the function with the following cloudbuild.yaml :

steps:
- name: 'gcr.io/cloud-builders/gcloud'
  args:
  - functions
  - deploy
  - pupetter-e2e
  - --source=.
  - --trigger-bucket homepage

(trigger described: https://cloud.google.com/functions/docs/deploying/filesystem )

or alternatively:

steps:
- name: 'gcr.io/cloud-builders/gcloud'
  args:
  - functions
  - deploy
  - pupetter-e2e
  - --source=.
  - --trigger-resource hjemmeside  
  - --trigger-event google.storage.object.finalize

(as described as https://cloud.google.com/functions/docs/calling/storage ) sadly, I get

ERROR: (gcloud.functions.deploy) unrecognized arguments: --trigger-bucket hjemmeside (did you mean '--trigger-bucket'?) or --trigger-resource hjemmeside (did you mean --trigger-resource?)

I have attempted to use --trigger-bucket , but can not get it to work properly. Could someone please help me by correcting the mistake in my cloudbuild.yaml ?

You have 2 solution to solve this (and even more, but 2 is already good). Firstly, Space aren't accepted in the args list, so:

  • Replace the space by an equal.
steps:
- name: 'gcr.io/cloud-builders/gcloud'
  args:
  - functions
  - deploy
  - pupetter-e2e
  - --source=.
  - --trigger-bucket=homepage
  • Put the param value in a new ARGS value (new line)
steps:
- name: 'gcr.io/cloud-builders/gcloud'
  args:
  - functions
  - deploy
  - pupetter-e2e
  - --source=.
  - --trigger-bucket 
  - homepage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM