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

前端 未结 6 1118
野性不改
野性不改 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条回答
  •  孤独总比滥情好
    2021-02-09 02:14

    I did same thing few days ago.

    You can submit your builds using gcloud and rest api

    gcloud:

    gcloud builds submit --no-source  --config=cloudbuild.yaml --async --format=json
    

    Rest API:

    Send you cloudbuild.yaml as JSON with Auth Token to this url https://cloudbuild.googleapis.com/v1/projects/standf-188123/builds?alt=json

    example cloudbuild.yaml:

    steps:
    
    - name: 'gcr.io/cloud-builders/docker'
      id: Docker Version
      args: ["version"]
    
    - name: 'alpine'
      id:  Hello Cloud Build
      args: ["echo", "Hello Cloud Build"]
    

    example rest_json_body:

    {"steps": [{"args": ["version"], "id": "Docker Version", "name": "gcr.io/cloud-builders/docker"}, {"args": ["echo", "Hello Cloud Build"], "id": "Hello Cloud Build", "name": "alpine"}]}
    

提交回复
热议问题