How to deploy a function on GCP with Cloud Build?

2.2k Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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