如何通过cli/rest api/cloud函数运行Google Cloud Build触发器? [英] How to run a Google Cloud Build trigger via cli / rest api / cloud functions?

查看:51
本文介绍了如何通过cli/rest api/cloud函数运行Google Cloud Build触发器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有这样的选择吗?我的用例将运行生产构建的触发器(部署到生产).理想情况下,该触发器不需要侦听任何更改,因为它是通过chatbot手动调用的.

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 it is invoked manually via chatbot.

我看到了此视频面向混合云和多云客户的CI/CD(Cloud Next '18)宣布有API触发器支持,我不确定是否正是我所需要的.

I saw this video CI/CD for Hybrid and Multi-Cloud Customers (Cloud Next '18) announcing there's an API trigger support, I'm not sure if that's what I need.

推荐答案

几天前我做过同样的事情.

I did same thing few days ago.

您可以使用gcloud和rest api提交构建

You can submit your builds using gcloud and rest api

gcloud:

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

其他API:

使用身份验证令牌将您的cloudbuild.yaml作为JSON发送到此URL https://cloudbuild.googleapis.com/v1/projects/standf-188123/builds?alt=json

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

示例cloudbuild.yaml:

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"]

示例rest_json_body:

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"}]}

这篇关于如何通过cli/rest api/cloud函数运行Google Cloud Build触发器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆