使用 pact-provider-verifier 时出现“未找到所选消费者版本的协议”

问题描述 投票:0回答:1

当我运行以下命令时,我收到“未找到所选消费者版本的协议”:

pact-provider-verifier --publish-verification-results true --provider-app-version "1.0.8" --provider-base-url myCompanyURL --provider "Core.IApi.Cards.Api" --consumer-version-tag '{"branch":"feature\AUTHSUS23-93"}'

我像这样向 Pactflow 发布了我的消费者合同

Pact-broker publish ./pacts -b myCompanyURL  --consumer-app-version="1.0.6" -k IOGckfk69pM3JVOxxZ4vPg --branch "feature/AUTHSUS23-93" --tag "feature"

我可以看到它在 Pactflow 中更新了这些值

然后将这样的提供商合约发布到 Pactflow

pactflow publish-provider-contract CardsAPIProviderContract.json --provider  "Core.IApi.Cards.Api" --provider-app-version  "1.0.8" -b https://thredd-processor.pactflow.io  -k IOGckfk69pM3JVOxxZ4vPg --content-type application/json --branch "providerFeatureBranch" --tag "feature"

我可以看到它在 Pactflow 中更新了这些值

那么我的契约提供者验证程序出了什么问题。 Pactflow 团队或专家能否帮我解决这里出了什么问题

pact pactflow
1个回答
0
投票

看起来您正在将消费者版本 selectors 传递给

--consumer-version tag
参数。该属性带有一个标签:

使用此消费者版本标签检索最新的协议。与--provider 结合使用。可以指定多次

您应该传递的是

--consumer-version-selector
参数。从
pact-provider-verifier help
输出(取自版本 1.36.1):

Usage:
  pact-provider-verifier PACT_URL ... -h, --provider-base-url=PROVIDER_BASE_URL

Options:
  -h, --provider-base-url=PROVIDER_BASE_URL                                  # Provider host URL
  -c, [--provider-states-setup-url=PROVIDER_STATES_SETUP_URL]                # Base URL to setup the provider states at
      [--pact-broker-base-url=PACT_BROKER_BASE_URL]                          # Base URL of the Pact Broker from which to retrieve the pacts. Can also be set using the environment variable PACT_BROKER_BASE_URL.
  -n, [--broker-username=BROKER_USERNAME]                                    # Pact Broker basic auth username. Can also be set using the environment variable PACT_BROKER_USERNAME.
  -p, [--broker-password=BROKER_PASSWORD]                                    # Pact Broker basic auth password. Can also be set using the environment variable PACT_BROKER_PASSWORD.
  -k, [--broker-token=BROKER_TOKEN]                                          # Pact Broker bearer token. Can also be set using the environment variable PACT_BROKER_TOKEN.
      [--provider=PROVIDER]                                                  
      [--consumer-version-tag=TAG]                                           # Retrieve the latest pacts with this consumer version tag. Used in conjunction with --provider. May be specified multiple times.
      [--provider-version-tag=TAG]                                           # Tag to apply to the provider application version. May be specified multiple times.
      [--provider-version-branch=BRANCH]                                     # The name of the branch the provider version belongs to.
  -g, [--tag-with-git-branch], [--no-tag-with-git-branch]                    # Tag provider version with the name of the current git branch. Default: false
  -a, [--provider-app-version=PROVIDER_APP_VERSION]                          # Provider application version, required when publishing verification results
  -r, [--publish-verification-results], [--no-publish-verification-results]  # Publish verification results to the broker. This can also be enabled by setting the environment variable PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=true
      [--enable-pending], [--no-enable-pending]                              # Allow pacts which are in pending state to be verified without causing the overall task to fail. For more information, see https://pact.io/pending
      [--custom-provider-header=CUSTOM_PROVIDER_HEADER]                      # Header to add to provider state set up and pact verification requests. eg 'Authorization: Basic cGFjdDpwYWN0'. May be specified multiple times.
      [--custom-middleware=FILE]                                             # Ruby file containing a class implementing Pact::ProviderVerifier::CustomMiddleware. This allows the response to be modified before replaying. Use with caution!
  -v, [--verbose=VERBOSE]                                                    # Verbose output. Can also be set by setting the environment variable VERBOSE=true.
  -f, [--format=FORMATTER]                                                   # RSpec formatter. Defaults to custom Pact formatter. Other options are json and RspecJunitFormatter (which outputs xml).
  -o, [--out=FILE]                                                           # Write output to a file instead of $stdout.
      [--wait=SECONDS]                                                       # The number of seconds to poll for the provider to become available before running the verification
                                                                             # Default: 0
      [--log-dir=LOG_DIR]                                                    # The directory for the pact.log file
      [--log-level=LOG_LEVEL]                                                # The log level
                                                                             # Default: debug
      [--fail-if-no-pacts-found], [--no-fail-if-no-pacts-found]              # If specified, will fail when no pacts are found

Description:
  The parameters used when fetching pacts dynamically from a Pact Broker are:
  
  --pact-broker-base-url (REQUIRED)
  --provider (REQUIRED)
  --broker-username/--broker-password or --broker-token
  --consumer-version-tag or --consumer-version-selector
  --enable-pending
  --include-wip-pacts-since
  
  To
  verify a pact at a known URL (eg. when a verification is triggered by a
  'contract content changed' webhook), pass in the pact URL(s) as the first
  argument(s) to the command, and do NOT set any of the other parameters apart
  from the base URL and credentials.
  
  To publish verification results for either of the above
  scenarios, set:
  
  --publish-verification-results (REQUIRED)
  --provider-app-version (REQUIRED)
  --provider-version-tag or --tag-with-git-branch
  
  
  Selectors: These are specified using JSON strings.
  The keys are 'tag' (the name of the consumer version tag), 'latest'
  (true|false), 'consumer', and 'fallbackTag'. For example '{\"tag\":
  \"master\", \"latest\": true}'. For a detailed explanation of selectors, see https://pact.io/selectors#consumer-version-selectors
© www.soinside.com 2019 - 2024. All rights reserved.