Is there a way to automatically add comments to any pull requests created in Azure DevOps within a repository?
-
How about the issue? Does the answer below resolved your question, If not, would you please let me know the latest information about this issue? – Leo Liu Aug 13 '20 at 09:22
3 Answers
Is there a way to automatically add comments to any pull requests created in Azure DevOps within a repository?
I am afraid there is no such way to automatically add comments to any pull requests created in Azure DevOps within a repository.
That because we are currently unable to monitor the creation of pull requests in real time. And there is no similar extension to detect the creation of pull requests. In this case, we could set the action to add comment to the all pull requests.
To achieve this, we could try to add a Build Validation for each branch, and use the REST API Pull Request Thread Comments - Create to add comments to the pull requests.
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/threads/{threadId}/comments?api-version=5.1
You could check this thread for the details info about how to use this REST API.
In this case, if we create any pull request, it will invoke the Build Validation to use REST API to add comments to the pull request.

- 71,098
- 10
- 114
- 135
Our team had similar needs so I created an Azure DevOps task to do just that:
Just add the task to your PR build and you're good to go.

- 2,705
- 3
- 29
- 46
Depending on your exact need, you may be able to use the "Automatically included reviewers" functionality that you get with branch policy. It has a custom message that can be configured to be included in every PR.

- 5,421
- 5
- 43
- 69