Skip to content

Instantly share code, notes, and snippets.

@MooreDerek
Created May 11, 2022 20:59
Show Gist options
  • Save MooreDerek/5e4b2c44de05612b6d30a9fd351fe8f6 to your computer and use it in GitHub Desktop.
Save MooreDerek/5e4b2c44de05612b6d30a9fd351fe8f6 to your computer and use it in GitHub Desktop.
Overriding GCloud Trigger substitutions from the command line

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment