0

our internally used development process demands that we formally prove that all commits that were pushed are covered by a review (=pull request).

I know that if we would have enabled branch protection since the beginning of existence of a repo and its branches no commit can be pushed to the protected branches without a review/pull request.

Our internal auditors unfortunately are not satisfied with only looking at pull requests and telling them "The process does not allow to not cover a commit with a review".

Any idea how this could be accomplished? Can I fetch all the data via REST API and create a report on my own or is there something already existing, did not find anything in that direction in the web ui.

Thank you

Marko
  • 929
  • 9
  • 27

1 Answers1

1

You can check out extension Pull Request Manager Hub. It can list your Pull Requests of all your projects and repositories at a single place.

After you install this extension in your organization. You can go the Pull Request Manager Hub under Repos from your Azure devops Project UI page to check out the reviewers, status and other details of the PR. See below:

enter image description here

You can also use rest api to get all the data and create a report on your own. See below Get Pull Requests rest api.

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId or repositoryName}/pullrequests?api-version=5.1

To get the reviewers you can use Pull Request Reviewers - List rest api.

See below example scripts in powershell to call rest api. Check here to get a personal access token.

$url ="https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId or repositoryName}/pullrequests?api-version=5.1"

$pat = "Personal Access Token"    

$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($pat)"))

$PRs=Invoke-RestMethod -Uri $url -Headers @{Authorization = ("Basic {0}" -f $base64AuthInfo)} -Method get -ContentType "application/json" 

$PRs.value | select pullRequestId, reviewers
Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43
  • It is not the perfect solution I was hoping to get but it is definitely very helpful. Thanks. – Marko Jun 01 '20 at 17:32