Hi All! Could you please help me with contract pub...
# pact-broker
t
Hi All! Could you please help me with contract publishing to a Pact Broker? I was able to run Pact Broker locally, I used docker image with my local DB, and now I can see UI in my browser. I followed these instructions. And I don’t use pactflow, just pact broker. Now I’d like to try to publish a contract to my Pact Broker and I am confused here, what I should do next? I see that I can use a CLI client with a docker image. But I don’t understand all parameters here 😞 and from what directory I should run the command. For example, I am trying to run the following command from my home directory:
Copy code
docker run --rm  \
  -e PACT_BROKER_BASE_URL=<http://localhost:9292>  \
  pactfoundation/pact-cli:latest \
  publish \
  /Users/tatiana/projects/project_name/contract-tests/pacts \
  --consumer-app-version fake-git-sha-for-demo-$(date +%s)
and I am getting the error:
Copy code
Specified pact file '/Users/tatiana/projects/project_name/contract-tests/pacts' does not exist. This sometimes indicates one of the arguments has been specified with the wrong name and has been incorrectly identified as a file path.
So, my questions: 1. Where should I run the docker command from? 2.
PACT_BROKER_USERNAME
and
PACT_BROKER_PASSWORD
are mandatory or they can be ignored? I didn’t set up these env variables when I was running
pactfoundation/pact-broker
image. Please point a right direction for me 🙏
Also, I see that I can use pact-broker such as
Copy code
pact-broker publish /path/to/pacts/consumer-provider.json --consumer-app-version 1.0.0 --branch main --broker-base-url <https://test.pactflow.io> --broker-token SomeToken
But in this case I can’t get how to run/setup
pact-broker
, I tried just to run docker image as
docker run pactfoundation/pact-cli
but it didn’t work
y
You need to volume mount your drive into the docker container as per the instructions in the linked docker readme.
☝️ 1
If trying to connect to a local broker, you need to tell your docker run command to connect to the host network, and volume mount the drive where your pacts reside https://github.com/YOU54F/path-to-pact-nirvana/blob/45550fa9ddb2c56bfa9b5d09c9193d06f99a9ec8/Step_04_PublishYourFirstPactLocally/Makefile#L14 Example here which publishes to a local broker stood up with docker compose. The endpoint needs to changed from localhost if on a Mac/windows machine, you can see it at the bottom of the file
t
Thank you very much. I was able to publish and verify the contract locally with pact broker 👍
y
Happy days rockon