Hi, I’m getting this error: `This version of the P...
# pact-broker
a
Hi, I’m getting this error:
This version of the Pact Broker requires that both consumer and provider are specified for a webhook.
running this example: https://github.com/pactflow/example-consumer/blob/master/Makefile#L114
m
what version of the broker are you using?
a
Copy code
After running PACT_BROKER_BASE_URL=<https://badger.pactflow.io/> PACT_BROKER_TOKEN=48XwmdOofoH_cxzqBawHnQ docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli version
I get 0.50.0
m
oh, you’re on pactflow. That’s the CLI version you’re reporting
Can you please share the error? That doesn’t seem right to me, but would need to double check
a
share the error? I have copied the error message
m
that’s the only message? With exactly the command in the Makefile? 🤔
a
This version of the Pact Broker requires that both consumer and provider are specified for a webhook. Please upgrade your broker to >= 2.22.0 to create a webhook with optional consumer and provider. make: * [create_or_update_github_commit_status_webhook] Error 1
that’s all i get
the command is this:
Copy code
# This webhook will update the Github commit status for this commit
# so that any PRs will get a status that shows what the status of
# the pact is.
create_or_update_github_commit_status_webhook:
	@"${PACT_CLI}" \
	  broker create-or-update-webhook \
	  '<https://api.github.com/repos/BadgerMaps/badger-docrouter/statuses/$${pactbroker.consumerVersionNumber}>' \
	  --header 'Content-Type: application/json' 'Accept: application/vnd.github.v3+json' 'Authorization: token $${user.githubCommitStatusToken}' \
	  --request POST \
	  --data @${PWD}/tests/contract/pact/github-commit-status-webhook.json \
	  --uuid ${GITHUB_WEBHOOK_UUID} \
	  --consumer ${PACTICIPANT} \
	  --provider ${PROVIDER} \
	  --contract-published \
	  --provider-verification-published \
	  --description "Github commit status webhook for ${PACTICIPANT}"
m
Interesting. I wonder if the CLI is looking at an old HAL relation or something. Pactflow always runs the latest (currently
-pact-broker-version: 2.93.3
if you introspect the headers)
I’ll follow up tomorrow
in the meantime, worth testing if you can do via the UI
a
i will try
👍 1
b
It's saying that because it can't find the relation that allows it to create the "new" style webhook with optional consumer/provider. Why it can't find it, I'm not sure.
It may be that your user doesn't have the webhook manage permissions @Antonio Gámiz Delgado
Ok, it's giving you a 405 when you try to create the webhook, according to this code https://github.com/pact-foundation/pact_broker-client/blob/master/lib/pact_broker/client/webhooks/create.rb#L56
Can you run it with verbose turned on?
VERBOSE=true
a
Hi! Sorry for the late response, I finally did it using it by hand (thanks @Matt (pactflow.io / pact-js / pact-go).
@Beth (pactflow.io/Pact Broker/pact-ruby) which user should have the webhook management permissions? The owner of the github token?
Also, do you know if there’s any docs for the --uuid ${GITHUB_WEBHOOK_UUID} option? I have been able to create the webhooks manually from the pactflow ui but I have not used that one so I’m curious
m
Copy code
pact-broker help 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.