From c1da32a9fd45591701ca3802fe8f27789db5f077 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Fri, 26 Aug 2022 12:10:15 +0100 Subject: [PATCH] docs: chore add publishing instructions --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/README.md b/README.md index f53125ca8..44d94e4b5 100644 --- a/README.md +++ b/README.md @@ -290,6 +290,54 @@ Like({ For more information see [Matching](https://docs.pact.io/getting_started/matching) +## Uploading pact files to a Pact Broker + +There are two ways to publish your pact files, to a Pact Broker. + +1. [Pact CLI tools](https://docs.pact.io/pact_broker/client_cli) **recommended** +2. Pact Python API + +### CLI + +See [Publishing and retrieving pacts](https://docs.pact.io/pact_broker/publishing_and_retrieving_pacts) + +Example uploading to a Pact Broker + +``` +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-username someUsername --broker-password somePassword +``` + +Example uploading to a Pactflow Broker + +``` +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 +``` + +### Python API + +```python +broker = Broker(broker_base_url="http://localhost") +broker.publish("TestConsumer", + "2.0.1", + branch='consumer-branch', + pact_dir='.') + +output, logs = verifier.verify_pacts('./userserviceclient-userservice.json') + +``` + +The parameters for this differ slightly in naming from their CLI equivalents: +| CLI | native Python | +|-----------------|-------------------------------------------------------------------------------------------------| +| `--branch` | `branch` | +| `--build-url` | `build_url` | +| `--auto-detect-version-properties` | `auto_detect_version_properties` | +| `--tag=TAG` | `consumer_tags` | +| `--tag-with-git-branch` | `tag_with_git_branch` | +| `PACT_DIRS_OR_FILES` | `pact_dir` | +| `--consumer-app-version` | `version` | +| `n/a` | `consumer_name` | + ## Verifying Pacts Against a Service In addition to writing Pacts for Python consumers, you can also verify those Pacts