Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Cloud Build triggered by Cloud Storage notifications question

I have GCP bucket, and I need to trigger Slack notification (using Cloud Build) if a new object created in certain folder. For example:
gs://mybucket/myfolder/example.zip
gs://mybucket/blah/myfolder/example.zip
gs://mybucket/blah/blah/myfolder/example.zip
So:
- I created Cloud Build job triggered by this Pub/Sub topic
Very simple, but - it seems that OBJECT_PREFIX doesn't support wildcards, i.e.
gcloud storage buckets notifications create gs://mybucket --object-prefix=myfolder/ ...
works for gs://mybucket/myfolder/myfile.zip but not for gs://mybucket/blah/myfolder/myfile.zip
Any ideas? (Yes, I can trigger w/o object prefix and filter relevant events in my cloud build job, but I don't want to trigger million jobs.)
Solved Solved
0 2 765
1 ACCEPTED SOLUTION

Hi @vitaly_il,

The documentation gcloud storage buckets notification create uses the example: photos/ as the value for the --object-prefix to filter the object they want to affect. If you want it to work for the blah folder then try changing your value to blah/.

Try experimenting by taking a look at URI Wildcards. gcloud storage and gsutil supports the use of URI wildcards for files, buckets, and objects.

If the above options don't work, you can contact Google Cloud Support to further look into your case. Let me know if it helped, thanks!

View solution in original post

2 REPLIES 2

Hi @vitaly_il,

The documentation gcloud storage buckets notification create uses the example: photos/ as the value for the --object-prefix to filter the object they want to affect. If you want it to work for the blah folder then try changing your value to blah/.

Try experimenting by taking a look at URI Wildcards. gcloud storage and gsutil supports the use of URI wildcards for files, buckets, and objects.

If the above options don't work, you can contact Google Cloud Support to further look into your case. Let me know if it helped, thanks!

>Try experimenting by taking a look at URI Wildcards 
I tried, but as far as I see, wildcards don't work for 'object-prefix'.

Thank you, I'll try to contact Google support.