When `pact-broker publish` fails and returns exit ...
# pact-broker
k
When
pact-broker publish
fails and returns exit code 1: How to figure out what is the reason for it to fail? It does not output anything (Version 1.68.0)
βœ… 1
m
Really? What about when using the verbose flag?
k
Can you share how to use it? The help page does not seem to mention its existence
m
pact-broker help publish
should get you all the available flags
Copy code
βœ— docker run pactfoundation/pact-cli:latest pact-broker help 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. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps.
  -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. 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]                                                    # 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.
so, adding just
--verbose
should do it
k
Ah god, the only way I have not tried to get the help πŸ˜„. Thank you
πŸ˜† 1
m
Yeah, for whatever reason, the most popular Ruby CLI builder (Thor) has a different way to provide help than most CLIs. But that’s how you do it!
k
Sure and of course once you do it an look closely enough (with --verbose) the error does not show again πŸ˜† . Apparently there is no output in the successful publish even with --verbose, would we have expected anything? + Are there any api downtimes or so known in the last few days on pactflow side?
πŸ˜† 1
m
Haha of course! I don't think we've any outages but the CLI is resilient to temporary issues (built in retries)
πŸ‘ 1
Yes, I would expect output with the verbose flag. It should show the full set of request/response calls. Mind showing how you're calling it? Is it in docker of anything?
k
Ok, sure this is how we call it. It is running within a dockerfile that was built from this Dockerfile:
Copy code
FROM pactfoundation/pact-ref-verifier:0.10.6 as pact-ref-verifier

FROM pactfoundation/pact-cli:0.54.0-pactcli0.53.0

COPY --from=pact-ref-verifier /usr/local/bin/pact_verifier_cli /bin/pact-verifier
RUN chmod a+x /bin/pact-verifier
y
I get the same behaviour if I have this erroneous character in between publish and the path to the pacts
>-
Copy code
docker run --rm -it pactfoundation/pact-cli:0.54.0-pactcli0.53.0 sh

~ # pact-broker publish example/pacts/pact.json --broker-base-url <https://test.pactflow.io> --broker-username dXfltyFMgNOFZAxr8io9wJ37iUpY42M --broker-password=O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1 -a 1.0.0
Updated docker-example-consumer version 1.0.0
  Next steps:
    Configure the version branch to be the value of your repository branch.
Pact successfully republished for docker-example-consumer version 1.0.0 and provider docker-example-provider with no content changes.
  View the published pact at <https://test.pactflow.io/pacts/provider/docker-example-provider/consumer/docker-example-consumer/version/1.0.0>
  Events detected: contract_published
  No enabled webhooks found for the detected events

~ # pact-broker publish >- example/pacts/pact.json --broker-base-url <https://test.pactflow.io> --broker-username dXfltyFMgNOFZAxr8io9wJ37iUpY42M --broker-password=O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1 -a 1.0.0
k
Thanks for noticing @Yousaf Nabi (pactflow.io) I think that was the problem. We seemed to have wrongly placed this gitlab-ci-yaml multiline symbol there. Without it we actually get the verbose content. 😊 πŸ‘
πŸ™Œ 1
m
Yep, great pickup indeed!