Hey! Im trying to publish my pacts to the pact bro...
# pact-broker
d
Hey! Im trying to publish my pacts to the pact broker in my ci workflow. I have the maven plugin (shown below) and my workflow (shown below). I get a 409 error stating "Each pact must be published with a unique consumer version number". Where exactly do i set the consumer version number?
m
Hi @Dominic Behrig, usually it should be the GitHub SHA. Depending on which CI you are using, this can be accessed by built-in environment variables. For example, if you are using GitHub actions, it's
${{ github.sha }}
. If you are using GitLab, it's
${CI_COMMIT_SHA}
d
Thanks for the reply. I understand it should be the sha but where/what exactly needs to be set? I tried setting <pacticipantVersion> under the maven plugin config but that didnt seem to work. I dont see a consumerVersion that can be set here. Also not sure if it matter but this is trying to upload 2 pact files. When the action runs the first pact file uploads no problem but the second one fails with the 409. Thanks for your help in advanced!
m
Ah, I see! Sorry I misunderstood the question. So, the version should be set when you run the command to upload the pact using the pact CLI. For example, something like:
Copy code
pact-broker publish ./pacts --consumer-app-version=$GITHUB_SHA --branch=$GITHUB_BRANCH --broker-base-url=$PACT_BROKER_BASE_URL --broker-token=$PACT_BROKER_TOKEN
From the above there is an option called
--consumer-app-version
. This is where you need to set itl
I'm not sure how to translate the above to your maven plugin config.