pactpact-java

Using Pact Broker


Can someone point me in detail as for how to publish JSON pacts in step by step to Pact Broker?

Have installed docker, dius/pack_broker and well as Postgres (brew installation).

Missing the point of mending all the above in a proper way and the appropriate script that will publish the JSON pact to pact broker.

To add, I'm using JVM implementation at the consumer side. And simple gradle verification at the provider side.


Solution

  • The Pact Broker is a restful API over a repository of pacts, so the simplest way to publish is to just do a PUT request to the broker with the contents of the generated pact files.

    As you have mentioned you're using Gradle, the Pact JVM Gradle plugin has a publish task which you could use. You just need to include the configuration in your consumer project and then execute the pactPublish task after running your tests.

    See https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-gradle#publishing-pact-files-to-a-pact-broker-version-227 for more information.