Configure webhook
To ensure that the verification step is run whenever a pact changes, we need to configure a webhook to trigger a provider verification build in Travis CI. The webhook will need an authentication token to be able to make this call to the Travis API. We don't want the Travis token to be stored in clear text in the webhook, so we will create a secret in Pactflow to contain token.
Copy your Travis CI token
- In Travis CI, click on your profile picture in the top right of the window, and select "Settings".
- Select the "Settings" tab.
- Under the API Authentication section, click "COPY TOKEN".
Create a Pactflow secret for the Travis token.
- In your Pactflow account, click on the Settings icon.
- Select the Secrets tab from the menu on the left.
- Click "ADD SECRET"
- Enter the name
travisToken
and paste the value that you copied earlier. - Click "CREATE"
Create the webhook.
In your Pactflow account, select the Webhooks tab from the settings page.
Click "ADD WEBHOOK".
Set:
Description:
Travis CI webhook for pactflow-example-providerConsumer: leave as "ALL"
Provider: select
pactflow-example-provider
Events: select
Contract published with changed content or tags
URL:
https://api.travis-ci.com/repo/<YOUR GITHUB ACCOUNT HERE>%2Fexample-provider/requestseg.
https://api.travis-ci.com/repo/bethesque%2Fexample-provider/requests
- you must leave the %2F in there.Headers:
Content-Type: application/jsonAccept: application/jsonTravis-API-Version: 3Authorization: token ${user.travisToken}Body:
{"request": {"message": "Triggered by changed pact for ${pactbroker.consumerName} version ${pactbroker.consumerVersionNumber}","branch": "master","merge_mode": "deep_merge_append","config": {"env": {"global": ["PACT_URL=${pactbroker.pactUrl}"]}}}}
Click the "TEST" button and ensure that it runs successfully.
Click the "CREATE" button.
Verify that the pact verification build for the provider is running correctly by opening Travis CI and checking the output of the triggered build.
๐ Each of the above steps can be automated - you can see the targets for them in the provider's Makefile.
Expected state by the end of this step
Both consumer and provider builds passing, and a webhook that has been tested and shown to trigger a pact verification build of the provider.