I'm trying to publish pact using the maven plugin ...
# pact-jvm
b
I'm trying to publish pact using the maven plugin available. Reading these docs: https://docs.pact.io/implementation_guides/jvm/provider/maven#configured-as-jvm-system-properties But im unable to set the consumer version. Ive tried
Copy code
mvn pact:publish -Dpact.publish.consumer.version=0.2-SNAPSHOT
export PACT_PUBLISH_CONSUMER_VERSION=0.2-SNAPSHOT
Neither seem to work. Im getting the following error from the plugin when running
mvn pact:publish
Copy code
Cannot change the content of the pact for Producer version 0.1-SNAPSHOT and provider Producer, as race conditions will cause unreliable results for can-i-deploy. Each pact must be published with a unique consumer version number
Can anyone tell me how i can increment the consumer version of the pact?
u
Can you provide debug logs?
m
the issue is that you are publishing a contract over an existing consumer version
you are saying “here is a new contract for version 0.2-SNAPSHOT of <consumer>”
this is bad, for the reasons shown in the error
you should ensure each time you run a build on new code, the version changes
if the contract is not expected to change (which usually means the code doesn’t change), the version sent to the broker doesn’t need to change either.
b
@Matt (pactflow.io / pact-js / pact-go) thanks for the explanation. Just so I understand you are saying the reason im seeing this error is because there has been no change on the contract between
0.1-SNAPSHOT
and
0.2-SNAPSHOT
?
Copy code
Each pact must be published with a unique consumer version number
This is what i thought I was doing by giving a newer version
m
I didn’t properly read your message, sorry Ben. Your question was how to bump the version, which I don’t know how to answer I’m afraid. According to this that key looks correct, assuming
-D
sets the system property as expected. The env var looks wrong though (and is exported after the publish command so would have no effect) it should be
PACT_PUBLISH_CONSUMER_VERSION
it seems
b
@Matt (pactflow.io / pact-js / pact-go) No worries thanks for looking into it though. After a little more reading it looks like I can do what i want via the pact_broker-cli so im going to go that route I think
👍 1
m
I generally would recommend the CLI also (we also have a docker image and standalone version of that. Search the docs for a link)
👏 1