Skip to content

A Ruby and CLI client for the Pact Broker. Publish and retrieve pacts and verification results.

Notifications You must be signed in to change notification settings

aushm/pact_broker-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pact Broker Client

A client for the Pact Broker. Publishes and retrieves pacts, verification results, pacticipants, pacticipant versions and tags. The functionality is available via a CLI, or via Ruby Rake tasks. You can also use the Pact CLI Docker image.

Build status

Gem Version

Trigger update to docs.pact.io

Installation

Docker

The Pact Broker CLI is packaged with the other Ruby command line tools in the pactfoundation/pact-cli Docker image.

docker pull pactfoundation/pact-cli:latest

Standalone executable

Download the latest pact-ruby-standalone package. You do not need Ruby to run the CLI, as the Ruby runtime is packaged with the executable using Travelling Ruby.

Ruby

Add gem 'pact_broker-client' to your Gemfile and run bundle install, or install the gem directly by running gem install pact_broker-client.

Connecting to a Pact Broker with a self signed certificate

To connect to a Pact Broker that uses custom SSL cerificates, set the environment variable $SSL_CERT_FILE or $SSL_CERT_DIR to a path that contains the appropriate certificate. Read more at https://docs.pact.io/pact_broker/advanced_topics/using-tls#for-non-jvm

Usage - CLI

The Pact Broker base URL can be specified either using the environment variable $PACT_BROKER_BASE_URL or the -b or --broker-base-url parameters.

Pact Broker authentication can be performed either using basic auth or a bearer token.

Basic auth parameters can be specified using the $PACT_BROKER_USERNAME and $PACT_BROKER_PASSWORD environment variables, or the -u or --broker-username and -p or --broker-password parameters.

Authentication using a bearer token can be specified using the environment variable $PACT_BROKER_TOKEN or the -k or --broker-token parameters. This bearer token authentication is used by Pactflow and is not available in the OSS Pact Broker, which only supports basic auth.

Pacts

publish

Usage:
  pact-broker publish PACT_DIRS_OR_FILES ... -a, --consumer-app-version=CONSUMER_APP_VERSION -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
      [--auto-detect-version-properties], [--no-auto-detect-version-properties]
              # Automatically detect the repository branch from known CI
                environment variables or git CLI.
  -t, [--tag=TAG]
              # Tag name for consumer version. Can be specified multiple
                times.
  -g, [--tag-with-git-branch], [--no-tag-with-git-branch]
              # Tag consumer version with the name of the current git branch.
                Default: false
      [--build-url=BUILD_URL]
              # The build URL that created the pact
      [--merge], [--no-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.
  -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]
              # Verbose output. Default: false

Publish pacts to a Pact Broker.

list-latest-pact-versions

Usage:
  pact-broker list-latest-pact-versions -b, --broker-base-url=BROKER_BASE_URL

Options:
  -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]
              # Verbose output. Default: false
  -o, [--output=OUTPUT]
              # json or table
              # Default: table

List the latest pact for each integration

Environments

create-environment

Usage:
  pact-broker create-environment --name=NAME -b, --broker-base-url=BROKER_BASE_URL

Options:
      --name=NAME
              # The uniquely identifying name of the environment as used in
                deployment code
      [--display-name=DISPLAY_NAME]
              # The display name of the environment
      [--production], [--no-production]
              # Whether or not this environment is a production environment.
                Default: false
      [--contact-name=CONTACT_NAME]
              # The name of the team/person responsible for this environment
      [--contact-email-address=CONTACT_EMAIL_ADDRESS]
              # The email address of the team/person responsible for this
                environment
  -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]
              # Verbose output. Default: false

Create an environment resource in the Pact Broker to represent a real world deployment or release environment.

update-environment

Usage:
  pact-broker update-environment --uuid=UUID -b, --broker-base-url=BROKER_BASE_URL

Options:
      --uuid=UUID
              # The UUID of the environment to update
      [--name=NAME]
              # The uniquely identifying name of the environment as used in
                deployment code
      [--display-name=DISPLAY_NAME]
              # The display name of the environment
      [--production], [--no-production]
              # Whether or not this environment is a production environment.
                Default: false
      [--contact-name=CONTACT_NAME]
              # The name of the team/person responsible for this environment
      [--contact-email-address=CONTACT_EMAIL_ADDRESS]
              # The email address of the team/person responsible for this
                environment
  -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]
              # Verbose output. Default: false

Update an environment resource in the Pact Broker.

describe-environment

Usage:
  pact-broker describe-environment --uuid=UUID -b, --broker-base-url=BROKER_BASE_URL

Options:
      --uuid=UUID
              # The UUID of the environment to describe
  -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]
              # Verbose output. Default: false

Describe an environment

delete-environment

Usage:
  pact-broker delete-environment --uuid=UUID -b, --broker-base-url=BROKER_BASE_URL

Options:
      --uuid=UUID
              # The UUID of the environment to delete
  -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]
              # Verbose output. Default: false

Delete an environment

list-environments

Usage:
  pact-broker list-environments -b, --broker-base-url=BROKER_BASE_URL

Options:
  -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]
              # Verbose output. Default: false

List environments

Deployments

record-deployment

Usage:
  pact-broker record-deployment --environment=ENVIRONMENT -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL -e, --version=VERSION

Options:
  -a, --pacticipant=PACTICIPANT
              # The name of the pacticipant that was deployed.
  -e, --version=VERSION
              # The pacticipant version number that was deployed.
      --environment=ENVIRONMENT
              # The name of the environment that the pacticipant version was
                deployed to.
      [--application-instance=APPLICATION_INSTANCE]
              # Optional. The application instance to which the deployment has
                occurred - a logical identifer required to differentiate
                deployments when there are multiple instances of the same
                application in an environment. This field was called 'target'
                in a beta release.
      [--target=TARGET]
              # Renamed to application_instance
  -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]
              # Verbose output. Default: false

Record deployment of a pacticipant version to an environment. See https://docs.pact.io/record-deployment for more information.

record-undeployment

Usage:
  pact-broker record-undeployment --environment=ENVIRONMENT -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL

Options:
  -a, --pacticipant=PACTICIPANT
              # The name of the pacticipant that was undeployed.
      --environment=ENVIRONMENT
              # The name of the environment that the pacticipant version was
                undeployed from.
      [--application-instance=APPLICATION_INSTANCE]
              # Optional. The application instance from which the application
                is being undeployed - a logical identifer required to
                differentiate deployments when there are multiple instances of
                the same application in an environment. This field was called
                'target' in a beta release.
      [--target=TARGET]
              # Optional. The target that the application is being undeployed
                from - a logical identifer required to differentiate
                deployments when there are multiple instances of the same
                application in an environment.
  -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]
              # Verbose output. Default: false

Description: Note that use of this command is only required if you are permanently removing an application instance from an environment. It is not required if you are deploying over a previous version, as record-deployment will automatically mark the previously deployed version as undeployed for you. See https://docs.pact.io/record-undeployment for more information.

Releases

record-release

Usage:
  pact-broker record-release --environment=ENVIRONMENT -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL -e, --version=VERSION

Options:
  -a, --pacticipant=PACTICIPANT
              # The name of the pacticipant that was released.
  -e, --version=VERSION
              # The pacticipant version number that was released.
      --environment=ENVIRONMENT
              # The name of the environment that the pacticipant version was
                released to.
  -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]
              # Verbose output. Default: false

Record release of a pacticipant version to an environment. See See https://docs.pact.io/record-release for more information.

record-support-ended

Usage:
  pact-broker record-support-ended --environment=ENVIRONMENT -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL -e, --version=VERSION

Options:
  -a, --pacticipant=PACTICIPANT
              # The name of the pacticipant.
  -e, --version=VERSION
              # The pacticipant version number for which support is ended.
      --environment=ENVIRONMENT
              # The name of the environment in which the support is ended.
  -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]
              # Verbose output. Default: false

Record the end of support for a pacticipant version in an environment. See https://docs.pact.io/record-support-ended for more information.

Matrix

can-i-deploy

Usage:
  pact-broker can-i-deploy -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL

Options:
  -a, --pacticipant=PACTICIPANT
              # The pacticipant name. Use once for each pacticipant being
                checked.
  -e, [--version=VERSION]
              # The pacticipant version. Must be entered after the
                --pacticipant that it relates to.
      [--ignore=IGNORE]
              # The pacticipant name to ignore. Use once for each pacticipant
                being ignored. A specific version can be ignored by also
                specifying a --version after the pacticipant name option.
  -l, [--latest=[TAG]]
              # Use the latest pacticipant version. Optionally specify a TAG
                to use the latest version with the specified tag.
      [--to-environment=ENVIRONMENT]
              # The environment into which the pacticipant(s) are to be
                deployed
      [--branch=BRANCH]
              # The branch of the version for which you want to check the
                verification results
      [--to=TAG]
              # The tag that represents the branch or environment of the
                integrated applications for which you want to check the
                verification result status.
  -o, [--output=OUTPUT]
              # json or table
              # Default: table
      [--retry-while-unknown=TIMES]
              # The number of times to retry while there is an unknown
                verification result (ie. the provider verification is likely
                still running)
              # Default: 0
      [--retry-interval=SECONDS]
              # The time between retries in seconds. Use in conjuction with
                --retry-while-unknown
              # Default: 10
      [--dry-run], [--no-dry-run]
              # When dry-run is enabled, always exit process with a success
                code. Can also be enabled by setting the environment variable
                PACT_BROKER_CAN_I_DEPLOY_DRY_RUN=true.
  -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]
              # Verbose output. Default: false

Description: Returns exit code 0 or 1, indicating whether or not the specified application (pacticipant) has a successful verification result with each of the application versions that are already deployed to a particular environment. Prints out the relevant pact/verification details, indicating any missing or failed verification results.

The can-i-deploy tool was originally written to support specifying versions and dependencies using tags. This usage has now been superseded by first class support for environments, deployments and releases. For documentation on how to use can-i-deploy with tags, please see https://docs.pact.io/pact_broker/client_cli/can_i_deploy_usage_with_tags/

Before can-i-deploy can be used, the relevant environment resources must first be created in the Pact Broker using the create-environment command. The "test" and "production" environments will have been seeded for you. You can check the existing environments by running pact-broker list-environments. See https://docs.pact.io/pact_broker/client_cli/readme#environments for more information.

$ pact-broker create-environment --name "uat" --display-name "UAT" --no-production

After an application is deployed or released, its deployment must be recorded using the record-deployment or record-release commands. See https://docs.pact.io/pact_broker/recording_deployments_and_releases/ for more information.

$ pact-broker record-deployment --pacticipant Foo --version 173153ae0 --environment uat

Before an application is deployed or released to an environment, the can-i-deploy command must be run to check that the application version is safe to deploy with the versions of each integrated application that are already in that environment.

$ pact-broker can-i-deploy --pacticipant PACTICIPANT --version VERSION --to-environment ENVIRONMENT

Example: can I deploy version 173153ae0 of application Foo to the test environment?

$ pact-broker can-i-deploy --pacticipant Foo --version 173153ae0 --to-environment test

Can-i-deploy can also be used to check if arbitrary versions have a successful verification. When asking "Can I deploy this application version with the latest version from the main branch of another application" it functions as a "can I merge" check.

$ pact-broker can-i-deploy --pacticipant Foo 173153ae0 \ --pacticipant Bar --latest main

Pacticipants

create-or-update-pacticipant

Usage:
  pact-broker create-or-update-pacticipant --name=NAME -b, --broker-base-url=BROKER_BASE_URL

Options:
      --name=NAME
              # Pacticipant name
      [--display-name=DISPLAY_NAME]
              # Display name
      [--main-branch=MAIN_BRANCH]
              # The main development branch of the pacticipant repository
      [--repository-url=REPOSITORY_URL]
              # The repository URL of the pacticipant
  -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]
              # Verbose output. Default: false

Create or update pacticipant by name

describe-pacticipant

Usage:
  pact-broker describe-pacticipant --name=NAME -b, --broker-base-url=BROKER_BASE_URL

Options:
      --name=NAME
              # Pacticipant name
  -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]
              # Verbose output. Default: false

Describe a pacticipant

list-pacticipants

Usage:
  pact-broker list-pacticipants -b, --broker-base-url=BROKER_BASE_URL

Options:
  -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]
              # Verbose output. Default: false

List pacticipants

Webhooks

create-webhook

Usage:
  pact-broker create-webhook URL -X, --request=METHOD -b, --broker-base-url=BROKER_BASE_URL

Options:
  -X, --request=METHOD
              # Webhook HTTP method
  -H, [--header=one two three]
              # Webhook Header
  -d, [--data=DATA]
              # Webhook payload (file or string)
  -u, [--user=USER]
              # Webhook basic auth username and password eg. username:password
      [--consumer=CONSUMER]
              # Consumer name
      [--consumer-label=CONSUMER_LABEL]
              # Consumer label, mutually exclusive with consumer name
      [--provider=PROVIDER]
              # Provider name
      [--provider-label=PROVIDER_LABEL]
              # Provider label, mutually exclusive with provider name
      [--description=DESCRIPTION]
              # Webhook description
      [--contract-content-changed], [--no-contract-content-changed]
              # Trigger this webhook when the pact content changes
      [--contract-published], [--no-contract-published]
              # Trigger this webhook when a pact is published
      [--provider-verification-published], [--no-provider-verification-published]
              # Trigger this webhook when a provider verification result is
                published
      [--provider-verification-failed], [--no-provider-verification-failed]
              # Trigger this webhook when a failed provider verification
                result is published
      [--provider-verification-succeeded], [--no-provider-verification-succeeded]
              # Trigger this webhook when a successful provider verification
                result is published
      [--contract-requiring-verification-published], [--no-contract-requiring-verification-published]
              # Trigger this webhook when a contract is published that
                requires verification
      [--team-uuid=UUID]
              # UUID of the Pactflow team to which the webhook should be
                assigned (Pactflow only)
  -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]
              # Verbose output. Default: false

Description: Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-webhook" and add the consumer, provider, event types and broker details. Note that the URL must be the first parameter when executing create-webhook.

Note that the -u option from the curl command clashes with the -u option from the pact-broker CLI. When used in this command, the -u will be used as a curl option. Please use the --broker-username or environment variable for the Pact Broker username.

create-or-update-webhook

Usage:
  pact-broker create-or-update-webhook URL --uuid=UUID -X, --request=METHOD -b, --broker-base-url=BROKER_BASE_URL

Options:
  -X, --request=METHOD
              # Webhook HTTP method
  -H, [--header=one two three]
              # Webhook Header
  -d, [--data=DATA]
              # Webhook payload (file or string)
  -u, [--user=USER]
              # Webhook basic auth username and password eg. username:password
      [--consumer=CONSUMER]
              # Consumer name
      [--consumer-label=CONSUMER_LABEL]
              # Consumer label, mutually exclusive with consumer name
      [--provider=PROVIDER]
              # Provider name
      [--provider-label=PROVIDER_LABEL]
              # Provider label, mutually exclusive with provider name
      [--description=DESCRIPTION]
              # Webhook description
      [--contract-content-changed], [--no-contract-content-changed]
              # Trigger this webhook when the pact content changes
      [--contract-published], [--no-contract-published]
              # Trigger this webhook when a pact is published
      [--provider-verification-published], [--no-provider-verification-published]
              # Trigger this webhook when a provider verification result is
                published
      [--provider-verification-failed], [--no-provider-verification-failed]
              # Trigger this webhook when a failed provider verification
                result is published
      [--provider-verification-succeeded], [--no-provider-verification-succeeded]
              # Trigger this webhook when a successful provider verification
                result is published
      [--contract-requiring-verification-published], [--no-contract-requiring-verification-published]
              # Trigger this webhook when a contract is published that
                requires verification
      [--team-uuid=UUID]
              # UUID of the Pactflow team to which the webhook should be
                assigned (Pactflow only)
  -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]
              # Verbose output. Default: false
      --uuid=UUID
              # Specify the uuid for the webhook

Description: Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-or-update-webhook" and add the consumer, provider, event types and broker details. Note that the URL must be the first parameter when executing create-or-update-webhook and a uuid must also be provided. You can generate a valid UUID by using the generate-uuid command.

Note that the -u option from the curl command clashes with the -u option from the pact-broker CLI. When used in this command, the -u will be used as a curl option. Please use the --broker-username or environment variable for the Pact Broker username.

test-webhook

Usage:
  pact-broker test-webhook --uuid=UUID -b, --broker-base-url=BROKER_BASE_URL

Options:
      --uuid=UUID
              # Specify the uuid for the webhook
  -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]
              # Verbose output. Default: false

Test the execution of a webhook

Tags

create-version-tag

Usage:
  pact-broker create-version-tag -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL -e, --version=VERSION

Options:
  -a, --pacticipant=PACTICIPANT
              # The pacticipant name
  -e, --version=VERSION
              # The pacticipant version
  -t, [--tag=TAG]
              # Tag name for pacticipant version. Can be specified multiple
                times.
      [--auto-create-version], [--no-auto-create-version]
              # Automatically create the pacticipant version if it does not
                exist. Default: false
  -g, [--tag-with-git-branch], [--no-tag-with-git-branch]
              # Tag pacticipant version with the name of the current git
                branch. Default: false
  -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]
              # Verbose output. Default: false

Add a tag to a pacticipant version

Versions

describe-version

Usage:
  pact-broker describe-version -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL

Options:
  -a, --pacticipant=PACTICIPANT
              # The name of the pacticipant that the version belongs to.
  -e, [--version=VERSION]
              # The pacticipant version number.
  -l, [--latest=[TAG]]
              # Describe the latest pacticipant version. Optionally specify a
                TAG to describe the latest version with the specified tag.
  -o, [--output=OUTPUT]
              # json or table or id
              # Default: table
  -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]
              # Verbose output. Default: false

Describes a pacticipant version. If no version or tag is specified, the latest version is described.

create-or-update-version

Usage:
  pact-broker create-or-update-version -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL -e, --version=VERSION

Options:
  -a, --pacticipant=PACTICIPANT
              # The pacticipant name
  -e, --version=VERSION
              # The pacticipant version number
      [--branch=BRANCH]
              # The repository branch name
  -t, [--tag=TAG]
              # Tag name for pacticipant version. Can be specified multiple
                times.
  -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]
              # Verbose output. Default: false
  -o, [--output=OUTPUT]
              # json or text
              # Default: text

Create or update pacticipant version by version number

Miscellaneous

generate-uuid

Usage:
  pact-broker generate-uuid

Options:

Generate a UUID for use when calling create-or-update-webhook

Usage - Ruby

Consumer

# In Gemfile

gem "pact_broker-client"
# In Rakefile

require 'pact_broker/client/tasks'

PactBroker::Client::PublicationTask.new do | task |
  require 'my_consumer/version'
  task.consumer_version = ENV["GIT_COMMIT"]
  task.pattern = 'custom/path/to/pacts/*.json' # optional, default value is 'spec/pacts/*.json'
  task.pact_broker_base_url = "http://pact-broker"
  task.branch = ENV["GIT_BRANCH"] # Optional but STRONGLY RECOMMENDED.
  task.tag_with_git_branch = true|false # Superseeded by the `branch` property
  task.tags = ["dev"] # optional
  task.build_url = ENV["CI_BUILD_URL"]
  task.pact_broker_basic_auth =  { username: 'basic_auth_user', password: 'basic_auth_pass'} # optional
  task.pact_broker_token = "1234abcd" # Bearer token
  task.write_method = :merge # optional, this will merge the published pact into an existing pact rather than overwriting it if one exists. Not recommended, as it makes a mulch of the workflow on the broker.
end
# In CI script

bundle exec rake pact:publish

About

A Ruby and CLI client for the Pact Broker. Publish and retrieve pacts and verification results.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 97.8%
  • Shell 2.1%
  • Dockerfile 0.1%