If you’re using Travis CI, Code Climate, or one of many other CI tools with Github, you’ve probably noticed the little checklist of items that shows just above the “merge” button when you open a pull request.
These are called commit “statuses”, and there is a Github API for reporting these (Gitlab also has a similar API). If you are using a git sha for the consumer version number when you publish your pacts, you can now use Pact Broker webhooks to report the verification statuses of your pacts back to Github.
To do this, open up your Pact Broker API Browser, and click on the
NON-GET button next to the
pb:webhooks relation. Modify the JSON below to match your consumer, repository and Github auth details (we recommend you make a separate token for this purpose with the
repo:status grant), and click
If all your consumer names match their repository names in Github, you can make this a global webhook by removing the
consumer node and replacing the hardcoded
project name in the URL with the parameter
Want to use this cool feature? You’ll need version 2.21.0 or later of the Pact Broker.
Check out the webhook template library for more handy webhooks.
This post first appeared on the pact blog here and is re-posted with permission.
NOTE: The Pact Broker is an open source tool that requires you to deploy, administer and host it yourself. If you would prefer a plug-and-play option, we’ve created Pactflow, a fully managed Pact Broker with additional features to simplify teams getting started and scaling with Pact and contract testing. You can get started quickly and for free on our Developer Plan