Skip to main content

Publish Pacts

Code snippets to connect to your broker

Consumer

Pact JS (Node JS)

const { Publisher } = require("@pact-foundation/pact")
const opts = {
pactBroker: 'https://<YOUR_BROKER>.pactflow.io',
pactBrokerToken: '<TOKEN>',
consumerVersion: process.env.GIT_COMMIT
pactFilesOrDirs: ['./pacts'],
};

new Publisher(opts).publishPacts()

Branches

Configuring the branch when publishing pacts

See here for full docs.

pact-broker publish ./pacts --consumer-app-version $GIT_COMMIT --branch $GIT_BRANCH

# or

pact-broker publish ./pacts --auto-detect-version-properties