如何创建一个有效的 webhook,它可以由 pact broker 中的 Provider_verification_published 事件触发?

how to create a valid webhook which can be triggered by Provider_verification_published event in pact broker?

为了利用 pact broker webhook 自动执行合同测试,我使用 jenkins 作业创建了自定义 contract_content_changed 事件。但是当我尝试为由验证结果发布触发的客户管道添加webhook时,它失败了几次。

{"consumer": {
    "name": "Consumer Service"
  },
  "provider": {
    "name": "Provider Service"
  },
  "events": [
    {
      "name": "provider_verification_published"
    }
  ],
  "request": {
    "method": "POST",
    "url": "http://jenkinsserver/jobforconsumerdeployment",
    "headers": {
      "Accept": "application/json"
    },
   "body": {"VerificationResultURL","${pactbroker.verificationResultUrl}"
    }
}

删除正文元素后,创建成功。 通过将 body 传递给客户作业,它可以解析 fail/pass 并决定部署是否应该进行。

如果不允许正文,消费者管道如何获取结果并继续下一步(或停止部署)?

我指的是Pact Broker Webhooks

  1. 从构建触发器部分将 Jenkins 作业配置为 "Trigger builds remotely"
  2. 通过以下方式生成 Jenkins-Crumb link Steps to create Jenkins-Crumb
  3. 在 Pact-Broker 中遵循 post 请求对我来说工作正常 本地 jenkins 设置(需要检查 jenkin 权限以启用 网络挂钩执行) { "events": [{ "name": "provider_verification_published" }], "request": { "method": "GET", "url": "http://username:password@jenkins_url/job/jenkin_consumer/build?token=abc", "user" : "username:password", "headers": { "Jenkins-Crumb": "c787ce16220300f5ef8287a4474d9acxd" } } }

if body is not allowed, how consumer pipeline to get the result and continue next step (or stop deployment)?

是的,在 'provider_verification_published' 事件中不允许正文。所以为了确认验证结果,我们需要使用"can-i-deploy" cli部署或者停止部署can-i-deploy. More information provided on Pact Broker Webhooks