Hey folks, what's the recommended way to deal with...
# pact-broker
s
Hey folks, what's the recommended way to deal with monorepos and webhooks? We have a monorepo which hosts services like my-service and other-service. Whenever a webhook triggers, we get the
my-service
as a name, but I don't think there's a way to map it to a git repo - other than using an external datastore or a service, but nothing built into pact-broker. Is that correct, or am I missing some metadata?
cc @August Wang
m
I must admit it’s not something I’ve spent a lot of time doing (monorepo). Perhaps you could use one of the labels variants (e.g.
${pactbroker.providerLabels})
) to add some additional mapping in the broker? You could also lookup the git repo using that name. The pacticipant resource has a
repositoryUrl
property to store this sort of thing.
s
Thanks! How do you set the
repositoryUrl
field when creating or updating a pacticipant?
I've tried using a rest API directly and it works. I don't think default pact cli supports it, but we can use the rest api directly.
ah, nvm - you can use pact-broker cli to set repository url directly, sweet. I missed that part. So what we can do in our webhook processor service is to fetch provider details by name, extract repository url. @August Wang this is likely the best solution for us
a
Yeah that sounds good. Thank you both!
m
nice! Let us know how you go folks
s
Just to circle back here. We have a small microservice that accepts webhooks and triggers CI builds. Originally written to bypass some API limitations of our CI system. In there we've added a call to the broker to read the repositoryUrl from the broker once webhook is received and use that information to trigger a CI build. So it was a pretty easy change to make. One improvement would be if the webhook payload already included all the pacticipant information for both provider and the consumer, like repositoryUrl and others, but it's not a huge deal.
👍 1
m
That should be be doable. I'll raise a feature request to flesh it out further