How to run a Google Cloud Build trigger via cli / rest api / cloud functions?

前端 未结 6 1135
野性不改
野性不改 2021-02-09 01:53

Is there such an option? My use case would be running a trigger for a production build (deploys to production). Ideally, that trigger doesn\'t need to listen to any change since

6条回答
  •  梦毁少年i
    2021-02-09 02:27

    This now seems to be possible via API:

    https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.triggers/run

    request.json:

    {
      "projectId": "*****",
      "commitSha": "************"
    }
    

    curl request (with using a gcloud command):

    PROJECT_ID="********" TRIGGER_ID="*******************"; 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
    

提交回复
热议问题