问题
How can I get the Pull Request Id via a Build Id? Is there any existing Rest API to support this?
回答1:
You can get the build details with Builds - Get Rest API (you just need the Build Id):
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=5.0
In the JSON response, you got also the Pull Request Id:
"parameters":"{
\"system.pullRequest.pullRequestId\":\"1\",\"system.pullRequest.sourceBranch\":\"refs/heads/build\",\"system.pullRequest.targetBranch\":\"refs/heads/master\",\"system.pullRequest.sourceCommitId\":\"2e9f40aee78e1c916a6d6715ce9727d9bfbe940c\",\"system.pullRequest.sourceRepositoryUri\":\"https://shaykia@dev.azure.com/shaykia/Test/_git/Test\"}",
来源:https://stackoverflow.com/questions/54901768/how-can-i-get-the-pullrequestid-via-a-buildid