Hello, Is there a way to combine multiple contrac...
# pactflow
b
Hello, Is there a way to combine multiple contracts into a single contract with all the interactions ? I am using two different CI pipelines to publish a contract to Pactflow and the second contract is always overriding the first one. Command used : docker run --rm -v ${PWD}:/mounted -w /mounted -e PACT_BROKER_BASE_URL="xxxx.pactflow.io" -e PACT_BROKER_TOKEN="xxxxxxx" pactfoundation/pact-cli:latest publish pact.json --consumer-app-version 1.0.0
y
if you upload a directory it will merge files before uploading. also the version number should ideally be something that changes when your code changes (like a commit hash)
b
Thanks Yousaf Nabi can't we merge a new contract file with the old one if our provider and consumer version and names are the same?
y
not after publishing to the broker, it has the potential to affect existing verification results. pact broker client does the merging pre publish (and will inform the user if any desc/prov state will clobber each other)
✅ 1
b
Okay. It worked for me . Thanks Yousaf
y
awesome, thank you for confirming Bogireddy!
m
There actually is a way to do what you want:
Copy code
pact-broker help publish
Usage:
  pact-broker publish PACT_DIRS_OR_FILES ... -b, --broker-base-url=BROKER_BASE_URL

Options:
  -a, [--consumer-app-version=CONSUMER_APP_VERSION]                                                                       # The consumer application version
  -h, [--branch=BRANCH]                                                                                                   # Repository branch of the consumer version
  -r, [--auto-detect-version-properties], [--no-auto-detect-version-properties], [--skip-auto-detect-version-properties]  # Automatically detect the repository commit, branch and build URL from known CI environment variables or git CLI. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps.
                                                                                                                          # Default: false
  -t, [--tag=TAG]                                                                                                         # Tag name for consumer version. Can be specified multiple times.
  -g, [--tag-with-git-branch], [--no-tag-with-git-branch], [--skip-tag-with-git-branch]                                   # Tag consumer version with the name of the current git branch. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps.
                                                                                                                          # Default: false
      [--build-url=BUILD_URL]                                                                                             # The build URL that created the pact
      [--merge], [--no-merge], [--skip-merge]                                                                             # If a pact already exists for this consumer version and provider, merge the contents. Useful when running Pact tests concurrently on different build nodes.
                                                                                                                          # Default: false
  -o, [--output=OUTPUT]                                                                                                   # json or text
                                                                                                                          # Default: text
  -b, --broker-base-url=BROKER_BASE_URL                                                                                   # The base URL of the Pact Broker
  -u, [--broker-username=BROKER_USERNAME]                                                                                 # Pact Broker basic auth username
  -p, [--broker-password=BROKER_PASSWORD]                                                                                 # Pact Broker basic auth password
  -k, [--broker-token=BROKER_TOKEN]                                                                                       # Pact Broker bearer token
  -v, [--verbose], [--no-verbose], [--skip-verbose]                                                                       # Verbose output.
                                                                                                                          # Default: false

Publish pacts to a Pact Broker.
Note the
--merge
flag. The issue is that a partially complete pact file will still trigger a verification, and then it will trigger another once you’ve finished uploading. I personally am not sure about this workflow, but I know we used to use it at PactFlow. So we know what we’re doing (apparently) trollparrot
✅ 1
b
Thanks Matt. I am combining multiple contracts before uploading to Pactflow.
🙌 1