Is there a CLI option for CloudBuild triggers patch command?
GCB API version has 'patch' option https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.triggers/patch
yet gcloud CLI doesn't have 'patch' listed https://cloud.google.com/sdk/gcloud/reference/beta/builds/triggers/
I tried gcloud beta builds triggers patch $trigger_name
, but it didn't work
My use case. I've got a folder with all GCB triggers and I'm using GCB itself to create new/update GCB triggers from trigger.yaml files in that folder. Currently it deletes all the triggers and recreates them from those files. Maybe patching is a better option so that I don't have too many trigger IDs.
steps:
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
echo 'Starting bash'
for gcb_trigger in folder/triggers/*.yaml; do
gcloud beta builds triggers delete "$(basename $gcb_trigger .yaml)" --quiet
done
for gcb_trigger in folder/triggers/*.yaml; do
gcloud beta builds triggers create cloud-source-repositories --trigger-config="$gcb_trigger"
done
echo 'Finishing bash'
Patching triggers is not yet available via
gcloud
command, but it's possible to patch the triggers using the API inside thecurl
.On curl:
This request will update the name of your trigger to
foobar
.Take note that before doing this, you need to supply an access token for your auth header.