[英]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 部分中编辑分支保护规则时,我没有看到管道。
我怀疑我缺少一些触发器/挂钩配置,任何帮助将不胜感激。
要使用 GitHub 状态检查,首先,为存储库创建一个管道并至少构建一次,以便将其状态发布到 GitHub,从而使 GitHub 知道管道的名称。 接下来,按照 GitHub 的文档在存储库的设置中配置受保护的分支。 您可以按照此文档: 受保护的分支如果您想使用触发器设置,我们建议您将 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"}'
{my-PAT} 是个人访问令牌,它的 scope 必须是 'repo:state' (或更多)
{commit-sha} 应该能够在运行时找到,请查看此文档,其中包含管道/容器的示例。 我的案例是管道资源(不是存储库):
resources.pipeline..sourceBranch 资源.pipeline..sourceCommit
我想所有其他 {my-*} 值都很清楚。
在成功请求之后,我在可用状态检查列表中找到了标题为default
的行。 根据文档,它可以更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.