Skip to content

Publishing and retrieving pacts

Beth Skurrie edited this page Jul 3, 2017 · 25 revisions

Publishing

If you have a Ruby project, use the pact_broker-client gem.

If you don't, then you can use a curl request like the following to PUT the pact to the right location, specifying your consumer name, provider name and consumer version.

curl -v -XPUT \-H "Content-Type: application/json" \
-d@spec/pacts/a_consumer-a_provider.json \
http://your-pact-broker/pacts/provider/A%20Provider/consumer/A%20Consumer/version/1.0.0

The version will be parsed using Versionomy and would typically be in the format x.x.x, though you can read the Versionomy docs for the full range of version formats that can be accepted.

Retrieving

Use the HAL Browser to explore more endpoints in the pact broker.

Latest pact for a provider and consumer

http://your-pact-broker/pacts/provider/PROVIDER_NAME/consumer/CONSUMER_NAME/latest

If you want to use tagging to enable you to effectively make "feature branch pacts", then you should verify the latest-untagged instead of the latest.

http://your-pact-broker/pacts/provider/PROVIDER_NAME/consumer/CONSUMER_NAME/latest-untagged

To retrieve the latest pact for a given tag, use:

http://your-pact-broker/pacts/provider/PROVIDER_NAME/consumer/CONSUMER_NAME/latest/TAG

Latest pacts for a provider

http://your-pact-broker/pacts/provider/PROVIDER_NAME/latest

All latest pacts

http://your-pact-broker/pacts/latest