最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

events - Azure DevOps Webhook for Pull Request Approval (git.pullrequest.approved) Not Available in UI - Stack Overflow

programmeradmin3浏览0评论

I’m trying to create a webhook in Azure DevOps to trigger when a pull request is approved. According to Microsoft’s official documentation, there is an event type called git.pullrequest.approved:

Microsoft Docs - git.pullrequest.approved

However, when setting up a Service Hook Subscription in Azure DevOps, I do not see this event listed under the available pull request triggers. The only available PR-related events are:

•   git.pullrequest.created
•   git.pullrequest.updated
•   git.pullrequest.merge attempted
•   git.pullrequestment
•   etc.

My questions:

  1. Is the git.pullrequest.approved event actually available?

If so, how can I enable or find it in the Azure DevOps UI?

  1. If this event doesn’t exist, what is the best alternative to track PR approvals?
    • Should I use git.pullrequest.updated with a filter on vote changes?
    • Is there a way to extract the timestamp when a PR is approved?

Any insights would be greatly appreciated! Thanks in advance

I’m trying to create a webhook in Azure DevOps to trigger when a pull request is approved. According to Microsoft’s official documentation, there is an event type called git.pullrequest.approved:

Microsoft Docs - git.pullrequest.approved

However, when setting up a Service Hook Subscription in Azure DevOps, I do not see this event listed under the available pull request triggers. The only available PR-related events are:

•   git.pullrequest.created
•   git.pullrequest.updated
•   git.pullrequest.merge attempted
•   git.pullrequest.comment
•   etc.

My questions:

  1. Is the git.pullrequest.approved event actually available?

If so, how can I enable or find it in the Azure DevOps UI?

  1. If this event doesn’t exist, what is the best alternative to track PR approvals?
    • Should I use git.pullrequest.updated with a filter on vote changes?
    • Is there a way to extract the timestamp when a PR is approved?

Any insights would be greatly appreciated! Thanks in advance

Share Improve this question edited 18 hours ago Miao Tian-MSFT 5,5471 gold badge6 silver badges20 bronze badges asked yesterday pm141088pm141088 272 silver badges4 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

According to your description, I tested the issue and found the git.pullrequest.approved event is not listed under the available pull request triggers.

The Event ID described in the document is git.pullrequest.approved, but the sample says "eventType": "git.pullrequest.merged".

And after testing, I also found that if I select Pull request merge attempted event in the UI, the actual Event ID used is "eventType": "git.pullrequest.merged", which is not the Event ID described in the document: git.pullrequest.merge.attempted.

Thank you for noticing that there may be some problems with this document. You can report this issue here so that the relevant engineers can check and fix this problem.

Should I use git.pullrequest.updated with a filter on vote changes?

I tested the event, the webhook will be triggered when someone approves the pull request.

Is there a way to extract the timestamp when a PR is approved?

You can extract the createdDate field from the webhook payload to get the timestamp of the approval event.

If you are using the webhook based triggers for YAML pipelines, you can use ${{ parameters.MyWebhookTrigger.createdDate}} to get the createdDate field value.

trigger: none
resources:
  webhooks:
    - webhook: MyWebhookTrigger         ### Webhook name
      connection: MyWebhookConnection    ### Incoming webhook service connection name
pool:
  vmImage: windows-latest
steps:
- task: PowerShell@2
  inputs:
    targetType: 'inline'
    ### JSON payload data is available in the form of ${{ parameters.<WebhookAlias>.<JSONPath>}}
    script: |
      Write-Host "message:  ${{ parameters.MyWebhookTrigger.createdDate}}"

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论