It is possible to initiate a build trigger using gcloud
, it's as a easy as:
gcloud beta builds triggers run <TRIGGER_ID>
however, it is not possible to override any of the trigger substitutions using the gcloud
command line.
However, there is also a REST API that can be used to do the same thing. You'll need to be logged in
gcloud auth login
and have cURL
installed. Then create a request.json
file to hold the request details
{
"tagName": "v1.20",
"substitutions": {
"_DRY_RUN": "false"
}
}
Then send the payload with the trigger request:
curl -X POST -T request.json -H "Authorization: Bearer $(gcloud config config-helper \
--format='value(credential.access_token)')" \
https://cloudbuild.googleapis.com/v1/projects/"$PROJECT_ID"/triggers/"$TRIGGER_ID":run
This was inspired by this StackOverflow answer