pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 479 forks source link

Publishing pact files to a pact broker with pact-jvm-consumer-junit #822

Closed yoka791 closed 5 years ago

yoka791 commented 5 years ago

Hi, I am trying to use pact-jvm-consumer-junit for my consumer (it uses junit/spring). I want to publish the pact file to my pact broker during the CI. I saw here that the only (am I correct?) option to upload a pact from the consumer side is to use a plugin named pact-jvm-provider-gradle. There, when I add the plugin in pom.xml I can set pact broker's url/tag etc..

<dependencies>
..
    <dependency>
        <groupId>au.com.dius</groupId>
        <artifactId>pact-jvm-consumer-junit_2.12</artifactId>
        <version>3.5.24</version>
        <scope>test</scope>
    </dependency>

..
</dependencies>

<build>
    <plugins>
        ..
        <plugin>
            <groupId>au.com.dius</groupId>
            <artifactId>pact-jvm-provider-maven_2.12</artifactId>
            <version>3.5.24</version>
            <configuration>
                <pactBrokerUrl>http://192.168.132.220/</pactBrokerUrl>
                <pactDirectory>${project.build.directory}/pacts</pactDirectory> <!-- Defaults to ${project.build.directory}/pacts -->
                <projectVersion>${project.version}</projectVersion> <!-- Defaults to ${project.version} -->
                <tags>
                    <tag>feature/pact_test</tag>
                </tags>
                <trimSnapshot>true</trimSnapshot> <!-- Defaults to false -->
            </configuration>
        </plugin>
        ..
    </plugins>
</build>

But - I want to have an option to set those options during the build phase in the CI. How can I do that? Thanks.

uglyog commented 5 years ago

The Pact-JVM Maven plugin supports publishing pact files to a broker. See https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-maven#publishing-pact-files-to-a-pact-broker.

I'm not sure what you mean by "I want to have an option to set those options during the build phase in the CI". Do you mean the Maven build phase, or are you referring to a build step in your CI?

Maven does support project properties. Refer to the Maven docs on how to use those.

pawarsum commented 5 years ago

https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-maven#publishing-pact-files-to-a-pact-broker. Link is broken.

uglyog commented 5 years ago

@pawarsum use this URL https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-maven#publishing-pact-files-to-a-pact-broker

pmajcher commented 4 years ago

hi, I think this is current url https://github.com/DiUS/pact-jvm/tree/master/provider/maven#publishing-pact-files-to-a-pact-broker

jonrosner commented 2 years ago

Why is this plugin in a group that contains provider (au.com.dius.pact.provider) when actually you need it to publish consumer contracts as well? This confused me quite a lot.