POST body 用于 Google Cloud Build - Webhook 触发器

POST body for Google Cloud Build - Webhook Triggers

Google Cloud Build - Webhook 触发器 create trigger documentation 显示了正确的 URL 到 POST 来调用构建触发器。但是文档没有描述 POST body,这似乎是必需的。我已经使用 content-type: application/json header 和 {} 的 POST body 成功触发了云构建 webhooks,但很高兴知道:

接受了 Google Cloud Build - REST API documentation provides some additional hints that a HttpBody 有效负载,但据我所知没有其他信息。

body就是你想要的!事实上,在您的触发器中,您可以像这样自定义替换变量(来自文档)

 --subtitutions=\
         _SUB_ONE='$(body.message.test)', _SUB_TWO='$(body.message.output)'

所以,您的 body 需要像那样

{
  "message": {
    "test": "test value",
    "ourput": "my output"
  }
}

数据是从您的 body 内容中自动提取的。因此,您可以添加更多替换或更改 JSON 的格式,从而更改替换值的格式。