我正在尝试从构建管道页面中的提交哈希中获取拉取请求 ID(进入 master)。这是列出 PR 内的提交消息和文件所必需的。有办法获取吗?
谢谢!
最佳答案
您应该能够使用预定义的构建变量调用System.PullRequest.PullRequestId。可以找到 Azure DevOps 构建预定义变量的列表 here 。文档指出
The ID of the pull request that caused this build. For example: 17. (This variable is initialized only if the build ran because of a Git PR affected by a branch policy).
以下变量也可用
- System.PullRequest.PullRequestNumber
- System.PullRequest.SourceBranch
- System.PullRequest.SourceRepositoryURI
- System.PullRequest.TargetBranch
注意:这些变量在管道模板中不可用。
关于azure - 从 Azure DevOps 中的提交哈希获取拉取请求 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69892130/