如何通过BuildId获取PullRequestId?

时间:2019-02-27 09:12:38

标签: azure-devops azure-pipelines pull-request azure-devops-rest-api

如何通过构建ID获取拉取请求ID?是否有任何现有的Rest API支持此功能?

1 个答案:

答案 0 :(得分:1)

您可以使用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://shaykia@dev.azure.com/shaykia/Test/_git/Test\"}",