Search code examples
pactpact-brokerpact-jvm

Publish pacts to a pact broker using maven plugin


I was able to generate a pact file and then verify it using the maven plugin. Now, I am trying to publish the pacts using a pact broker.

What I have done so far is based on the below link- https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-maven#publishing-pact-files-to-a-pact-broker-version-320

<plugin>
 <groupId>au.com.dius</groupId>
 <artifactId>pact-jvm-provider-maven_2.11</artifactId>
 <version>3.5.5</version>
 <configuration>
   <pactDirectory>target/pacts</pactDirectory> <!-- Defaults to ${project.build.directory}/pacts -->
   <pactBrokerUrl>http://<localIP>:80</pactBrokerUrl>
   <projectVersion>1.0.100</projectVersion> <!-- Defaults to ${project.version} -->
   <trimSnapshot>true</trimSnapshot> <!-- Defaults to false -->
</configuration>
</plugin>

The question I have here is how do I generate the pactBrokerUrl? Does this involve using the dockerized image of the pact broker as stated here? https://github.com/DiUS/pact_broker-docker Or can I just use the Pact Broker Maven plugin by warmuuh?


Solution

  • you need to install the pact broker in a container as explained in the link in your question. the URL is the IP where the broker is installed. Also you need to use the maven plugin to callout your broker url.