Configure consumer and provider pipelines

Configure consumer pipeline

The source repositories are configured to use the Pactflow Github and Travis accounts, and the public broker at test.pactflow.io. You will need to update these settings to point to your own accounts.

  1. In .travis.yml of the example-consumer project, set PACT_BROKER_BASE_URL to the base URL of your own Pactflow account (you will have received an email with this information).

  2. To update the encrypted PACT_BROKER_TOKEN you will need to use the Travis CI CLI which is released as a Rubygem. To avoid having to install yet another dependency, we are using the lirantal/travis-cli docker image, which coincidentally is maintained by a long time Pact fan and user, the awesome @lirantal.

    1. Log in to your Pactflow account (https://<your-subdomain>.pactflow.io), and go to Settings > API Tokens.

    2. Click the Copy button for the read/write CI token.

    3. Open a terminal in the directory where you checked out your example-consumer.

      export PACT_BROKER_TOKEN="<paste your token here>"
      make travis_login # you'll need to input your github credentials and 2FA if configured
      make travis_encrypt_pact_broker_token
    4. Copy the output of the encrypt command, including the quotation marks, and replace the - secure: value in the env > global section of your .travis.yml file.

    5. Commit and push the changes to your .travis.yml file.

    6. Open the example-consumer project in Travis CI. This build should now successfully publish the pact, but it will fail on the can-i-deploy step when it tries to deploy. This is because the provider has not published a successful verification result for the pact.

NOTE: If you're unable to generate an encrypted token here, you can also set the credentials directly in Travis. Go to https://travis-ci.com/github/<your org>/<your project>/settings and choose "More options" > "Settings" > "Environment Variables" and set the PACT_BROKER_TOKEN environment variable.

Configure provider pipeline

๐Ÿ” Repeat the above instructions to configure the Pactflow account for your provider project.

Note:

  • You shouldn't need to repeat the Travis login step.
  • The environment variable must be encrypted in the context of the repository to which it will be added, so you can't just reuse the output of the encrypt step from the consumer project.

After you have pushed your changes to .travis.yml, the provider pipeline will run, fetching and verifying the configured pacts from your Pactflow account, and publishing the results back. The can-i-deploy command will pass, and allow the provider to be deployed.

Back to the consumer

โœ… If you would like to see all your builds go green, you can re-trigger the consumer build by selecting "More options" > "Trigger build" > "Trigger custom build".

Expected state by the end of this step

Both consumer and provider builds passing.