5

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?

ElFik
  • 897
  • 2
  • 13
  • 31
  • 1
    Currently the only workaround I see is adding a check for `body.resource.pullRequestStatus != "completed"` in our service code. At this point we have to return a successful status code (even though really we only want to accept requests where the status is completed), otherwise the webhook appears to lose its subscription – ElFik May 21 '19 at 21:44
  • As the explaination of `Pull request merge create`, it means the merge commit is created. That's why it triggered after your pull request is created. You can try with the event: `Pull request updated` – Mengdi Liang May 31 '19 at 10:34

1 Answers1

3

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

Fairoz
  • 828
  • 2
  • 8
  • 21