如何通过构建ID获取Pull Request ID?是否有任何现有的Rest API支持此功能?
您可以使用Builds - Get Rest API获取构建详细信息(您只需要构建ID):
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=5.0
在JSON响应中,您还获得了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://[email protected]/shaykia/Test/_git/Test\"}",