Hi all, random question. When the webhook exists i...
# general
m
Hi all, random question. When the webhook exists in both consumer and provider pipeline, how do you prevent an infinite loop of calling the webhook when the other pipeline is ran? one method I thought of was using a separate branch that does not include the webhook on the 'called' pipeline. However if its calling a separate branch it will be generating a contract that is not on master which may be old and not current. What is the best practice for this scenario?
t
Why would there be an infinite loop? Consumer publishes a contract (triggering provider verification) Provider verification runs …. triggering nothing
Or, if you want to trigger can-i-deploy, it would look like: Consumer publishes a contract (triggering provider verification) Provider verification runs …. triggering verification published Consumer deploy runs, triggering nothing
m
So the webhook to call the consumer should not be on the provider? What if you implement a change on the provider side? Would you look to compare what is uploaded to the broker for the consumer contract?
t
huh?
If you implement a change on the provider side, you already have the consumer contract
you don’t need a new contract
The diagrams here might help
m
Ok that makes sense
t
When the provider runs the verification, it asks the broker what the relevant contract(s) are
(I think maybe the webhooks get told which specific contract to pull - I don’t actually know, I’ve never used them)
m
Yeah that makes sense thanks
👍 1
t
You’re welcome. I’d like to diagram this better, but it’s kinda hard to find a diagram that works for all the different CI practices that people already have
m
The most common use case for webhooks is to trigger a provider build every time a pact changes, and to trigger a consumer build every time a verification is published. So here it mentions triggering the consumer build from a verification being published i.e. the provider has changed. So should the webhook only exist from one perspective and not both?
y
you use webhooks to trigger provider verification tasks based on pact url, when a consumer contract changes
t
They’re different webhooks. Because the contract is written by the consumer, you might want to kick off the provider build (to verify the consumer’s contract). At this point you probably can’t deploy (if the contract is new). When the contract is verified, you might want to kick off the consumer deploy.
y
you run a verification task based on consumer version selectors when the provider changes (or doesn't change, just on commit) - this pulls back any contracts matching the selectors, we recommed deployedOrReleased true and matchingBranch true
trigger a consumer build every time a verification is published.
you could trigger a consumer can-i-deploy after a verification, return a status check to github, or slack
provider verification result wouldn't trigger another consumer build of publishing pacts (even if it did, it would then be verified by the provider, so a new webhook wouldn't be triggered)
When the webhook exists in both consumer and provider pipeline
The same webhook wont exist in both (as a trigger) , consumer event triggers a webhook, which in turn triggers the provider verification. if you are talking about different webhooks you should be more specific in your question :)
(I think maybe the webhooks get told which specific contract to pull - I don’t actually know, I’ve never used them)
They do, they provide a pact url of the pact to be verified, if you use the new contract_requireing_verification_published event/webhook, then the provider side also gets a webhook fired for any deployed or released versions of the provider plus the head of the main branch. previously webhook
contract_content_changed
would only trigger against the head of master
t
and to trigger a consumer build every time a verification is published.
^ I think this is misleading. It should say “trigger a potential consumer deploy every time….” I see why you thought there was a circular dependency 😬
m
OK I read this whole thread, and was confused - but this exact point is the problem! I personally don’t like that framing, and wouldn’t recommend it myself. I personally wouldn’t trigger any consumer build related actions from webhooks. I think you’re better off publishing verification events to tools like Github for status checks to unblock PRs to say the consumer build is “mergeable” or “deployable”