In Google Cloud Build I select Triggers -> Create Trigger. For region I use us-central1. Event: Webhook Event.
Webhook URL preview shows me the following url:
https://cloudbuild.googleapis.com/v1/projects/PROJECT_ID/triggers/TRIGGER_NAME?key=XXXXXXXX&secret=XXXXXXXX
When I try to curl
it I got:
{
"error": {
"code": 404,
"message": "triggerError spanner trigger (11111111111, TRIGGER_NAME) not found",
"status": "NOT_FOUND"
}
}
This only happens when I create trigger in us-central1 region. Triggers created in global region works fine.
How should I tell cloudbuild.googleapis.com
to look for a trigger from region us-central1?
--- Update ---
This is the way I execute webhooks:
$ curl https://cloudbuild.googleapis.com/v1/projects/{PROJECT}/triggers/hello-central1:webhook \
-d key=xxx \
-d secret=xxx
# {
# "error": {
# "code": 404,
# "message": "triggerError spanner trigger (11111111111, hello-central1) not found",
# "status": "NOT_FOUND"
# }
# }
$ curl https://cloudbuild.googleapis.com/v1/projects/{PROJECT}/locations/us-central1/triggers/hello-central1:webhook \
-d key=xxx \
-d secret=xxx
# {
# "error": {
# "code": 400,
# "message": "Request contains an invalid argument.",
# "status": "INVALID_ARGUMENT"
# }
# }
$ curl https://cloudbuild.googleapis.com/v1/projects/{PROJECT}/triggers/{TRIGGER}:webhook \
-d name=projects/{PROJECT}/locations/us-central1/triggers/{TRIGGER} \
-d key=xxx \
-d secret=xxx
# {
# "error": {
# "code": 400,
# "message": "Request contains an invalid argument.",
# "status": "INVALID_ARGUMENT"
# }
# }
This is the way to execute trigger from region different from global:
curl https://cloudbuild.googleapis.com/v1/projects/$PROJECT/locations/$REGION/triggers/$TRIGGER:webhook \
-d key=$KEY \
-d secret=$SECRET \
-d trigger=$TRIGGER \
-d projectId=$PROJECT
Another way:
curl "https://cloudbuild.googleapis.com/v1/projects/$PROJECT/locations/$REGION/triggers/$TRIGGER:webhook?key=$KEY&secret=$SECRET&trigger=$TRIGGER&projectId=$PROJECT" -d {}
Yet another way:
curl -X POST -H Content-Type:application/json "https://cloudbuild.googleapis.com/v1/projects/$PROJECT/locations/$REGION/triggers/$TRIGGER:webhook?key=$KEY&secret=$SECRET&trigger=$TRIGGER&projectId=$PROJECT"