azure - 从 Azure DevOps 中的提交哈希获取拉取请求 ID

标签 azure azure-devops azure-devops-rest-api

我正在尝试从构建管道页面中的提交哈希中获取拉取请求 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/

相关文章:

azure - 如何从 Azure 函数访问 API(使用 Azure Ad B2C token 进行身份验证)?

azure-devops - 从 csproj 获取 Azure DevOps 中 Nuget 包步骤中的版本号

azure - 如何使用 API 或 CLI 获取 Azure Devops 项目中的用户列表

rest - 通过 REST API 将更新推送到 VSTS

azure - 使用Microsoft Hive ODBC驱动程序在Azure文档数据库和HDInsight上的Hive集成方面的问题

azure - 如何通过 REST 接口(interface)获取 Azure 托管身份的 token ?

azure - 如何使用pyspark以表格形式打印StringType()的 "dictionary"

azure - 获取c#中存储帐户文件共享中上传的所有文件

Azure DevOps 编译时间变量

Azure REST API 获取分支返回 0 个分支