Azure DevOps - Github 状态检查

Azure DevOps - Github status checks

我有 n+ github 个存储库,我想连接到 2 个单独的 Azure DevOps 管道。

我当前的推送触发设置是按以下方式使用 resources

resources: 
  repositories:
  - repository: self
    type: git
    name: woohoo/validation1
    trigger: none  # to avoid triggering the build for pipeline itself
  - repository: repo1
    type: githubenterprise
    name: woohoo/repo1
    endpoint: myendpoint
    trigger:  
      branches:
        include:
         - test/*
    pr: 
     branches:
      include:
       - '*' 
  - repository: repo2
    type: githubenterprise
    name: woohoo/repo2
    endpoint: myendpoint
    trigger:  
      branches:
        include:
         - test/*
    pr: 
     branches:
      include:
       - '*' 
  ...

这对于触发构建和 运行 它们非常有效,但仍然缺少状态检查。此外,在 中编辑 分支保护规则 时,我没有看到管道 Require status checks to pass before merging section.

我怀疑我缺少一些 triggers/hooks 配置,我们将不胜感激。

要使用 GitHub 状态检查, 首先,为存储库创建一个管道并至少构建一次,以便将其状态发布到 GitHub,从而使 GitHub 知道管道的名称。 接下来,按照 GitHub 的文档在存储库设置中配置受保护的分支。 您可以关注此文档:Protected branches 如果您想使用触发器设置,我们建议您将您的 yaml 更改为:

 - repository: repo1
    type: githubenterprise
    name: woohoo/repo1
    endpoint: myendpoint
    trigger:  
      branches:
        include:
         - test/*
    pr: 
     branches:
      include:
       - '*'  

对于此类问题,我只找到了一个解决方案。它是基于 doc

的直接 GitHub API 调用
curl \
   -X POST \
   -H "Accept: application/vnd.github.v3+json" \
   -u {my-name}:{my-PAT} \
   https://api.github.com/repos/{my-org}/{my-repo}/statuses/{commit-sha} \
   -d '{"state":"success", "description": "test status change"}'
  1. {my-PAT} 是 personal access token,它的范围必须是 'repo:state'(或更多)

  2. {commit-sha} 应该可以在运行时找到,查看 this doc 中的 pipeline/container 示例。我的案例是管道资源(不是存储库):

    resources.pipeline.[别名].sourceBranch

    resources.pipeline.[别名].sourceCommit

  3. 我想所有其他 {my-*} 值都很清楚。

成功请求后,我在可用状态检查列表中找到标题为default的行。基于doc可以改