Hi, I am running pact tests using gradle plugin `4...
# pact-jvm
i
Hi, I am running pact tests using gradle plugin
4.1.39
, using Pactflow as a pact broker. There is a several consumers for same provider, and I can run verification for all consumers using similar config:
Copy code
fromPactBroker {
   withSelectors {
      selector('tagConsumer1', true, null, 'Consumer1')
      selector('tagConsumer2', true, null, 'Consumer2')
   }
}
via command `./gradlew pactVerify -Ppact.verifier.publishResults=true -Dpact.provider.branch=
git branch --show-current
-Dpact.provider.tag=`git branch --show-current`` How can I run verification for only one specified consumer?
m
I think you can use
pact.filter.pacturl
which is for that use case (e.g. via webhooks) https://docs.pact.io/implementation_guides/jvm/provider/gradle
i
Seems like
pact.filter.pacturl
does not support wildcards. What do you think, is it worth feature request to get latest version of pact, if version not specified? Like
provider/ProviderName/consumer/ConsumerName/
instead
/provider/ProviderName/consumer/ConsumerName/version/a34fge
, as it can be hard to obtain version when running on CI/CD
m
What use case would you have for doing this?
if you want to specify a single pact, the main use case is for the
contract_requiring_verification_published
webhook (https://docs.pact.io/pact_broker/webhooks#the-contract-requiring-verification-published-event).
i.e. when a consumer publishes a new contract, it will trigger a webhook to fire if it hasn’t yet been verified. This is the use case for specifying a specific version of a contract
if you want latest, you can get that (follow the HAL resources to find the
latest
resource, which will be a pointer to the latest version, essentially). This is not particularly useful, because “latest” can be anything - the latest for the main branch, on a feature branch etc. So when you verify “latest” at the time of verification, you don’t actually know what you’re verifying. Selectors are a better way of specifying what you need
i
As I usually have commit hash as version, I would prefer fetch pact by tag, which usually more human readable, like ‘master’, ‘test’ etc. Can I get pact by tag for specified consumer and provider?
m
So back to the above, what’s the use case you’re trying to solve?
i
run provider verification on Jenkins, and, in most cases, use contract from consumer’s master branch
So, tag and branch name will be known
While version rather unknown as it usually commit hash
m
So why can't you use the selectors then? That's what they do - dynamically find the contracts based on given criteria
i
Because I want to have selectors for all consumers in withSelectors {} block, but have ability to run verification for one of them
m
When would you want to run the verification for just one of them? Silly question perhaps, but can you not just comment out the selector above which you don’t want?
i
Yes, it’s possible to comment out, or even add selector in gradle file dynamically at runtime. In most of cases we will run verification for all consumers at once, still, I think of possibility to convenient filtering declared selectors, in some cases, perhaps, we will want to run
pactVerify
for only one (or two etc) specified consumer/s