0
votes

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.

2
Happy to help, but would need to get more information as to what you've tried so we don't repeat yourself. You're right, it would be good to have a document to explain how to setup pact_broker. For the config, please look at the database config file within the repository and change it accordingly. - J_A_X
Hi J_A_X, I'm trying to create dokcerised pact broker and postgres using the link - github.com/DiUS/pact_broker-docker/blob/master/POSTGRESQL.md. Getting the following error on running the first command in it... docker: Error response from daemon: Mounts denied: The path /var/lib/postgresql/data is not shared from OS X and is not known to Docker. You can configure shared paths from Docker -> Preferences... -> File Sharing. See docs.docker.com/docker-for-mac/osxfs/#namespaces for more info. .. - Janani Sampath Kumar
I think you should update your question, as it currently stands, it reads as if you have a broker but can't connect the dots to publish/retrieve. From this comment, it appears you can't even start the broker. Secondly, this is more of a Docker question - it looks like you're trying to mount a volume in docker incorrectly. - Matthew Fellows
@JananiSampathKumar Let's tackle one question at a time. I see you create a new question around configuring pact_broker on Docker, which is good. Might be a good idea to delete this question until after you fixed your docker pact_broker issue, and ask a new one if something else arises. - J_A_X

2 Answers

4
votes

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.

0
votes

PACT Broker Setup Download Dockerized Pact Broker Image from Docker HUB https://hub.docker.com/r/dius/pact-broker/ And follow the Prerequisites & Getting Started section which is provided by PACT Foundation. In addition you need Postgres Docker Image. I recommend prepare docker compose file and run. By default PACT Broker run on PUMA which uses default port 9292. Here is the PACT Broker repository from PACT Foundation you can copy Docker Compose file from here. https://github.com/pact-foundation/pact-broker-docker