ElFik
ElFik

Reputation: 1027

How to call a webhook only when a pull request has been successfully merged into master?

We are using Azure DevOps webhooks to call into our service from our customers projects.

The intention is to seamlessly perform some actions over their repository once they've completed a PR into master branch.

In my tests, I've set up a webhook defined like so: Event hook subscription settings

You can see that we've configured our webhook to only be called on "pull request merge attempted" on a specific repo, into "master" branch when the merge is successful.

What I've observed is that this causes our webhook to be hit any time a commit is added to a pull request, instead of only when the pull request has been completed.

What is the correct mechanism to perform an action only on successful completed PRs into a specific branch?

Is there something we should do on our code to validate or is it something we should get our customers to set up differently in the service hooks subscription?

Upvotes: 5

Views: 3166

Answers (1)

Fairoz
Fairoz

Reputation: 878

You should use "Pull request updated" event and filter for "Status changed". This trigger events for any PR status changes. You could perform your action in your API only when the status changes to "completed".

enter image description here

Upvotes: 4

Related Questions