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.

  1. Copy your Travis CI token

    1. In Travis CI, click on your profile picture in the top right of the window, and select "Settings".
    2. Select the "Settings" tab.
    3. Under the API Authentication section, click "COPY TOKEN".
  2. Create a Pactflow secret for the Travis token.

    1. In your Pactflow account, click on the Settings icon.
    2. Select the Secrets tab from the menu on the left.
    3. Click "ADD SECRET"
    4. Enter the name travisToken and paste the value that you copied earlier.
    5. Click "CREATE"
  3. Create the webhook.

    1. In your Pactflow account, select the Webhooks tab from the settings page.

    2. Click "ADD WEBHOOK".

    3. Set:

      • Description:

        Travis CI webhook for pactflow-example-provider
      • Consumer: 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/requests

        eg. https://api.travis-ci.com/repo/bethesque%2Fexample-provider/requests - you must leave the %2F in there.

      • Headers:

        Content-Type: application/json
        Accept: application/json
        Travis-API-Version: 3
        Authorization: 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}"
        ]
        }
        }
        }
        }
    4. Click the "TEST" button and ensure that it runs successfully.

    5. Click the "CREATE" button.

  4. 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.