简体   繁体   English

让 Azure DevOps 审查 GitHub 拉取请求

[英]Let Azure DevOps review GitHub pull request

https://azurecomcdn.azureedge.net/cvt-15581a490a8fb478b3258ea2c0ebb74bfa82fabce2af64ffc38962598949b138/images/page/services/devops/pipelines/github-integrations.jpg

My code repo was in GitHub and my pipelines are configured in Azure DevOps.我的代码存储库在 GitHub 中,我的管道在 Azure DevOps 中配置。

I need to let Azure DevOps check and filter every pull request submitted to my GitHub repo and limit the pull request to be merged until it passes Azure DevOps build.我需要让 Azure DevOps 检查和过滤提交到我的 GitHub 存储库的每个拉取请求,并限制合并拉取请求,直到它通过 Azure DevOps 构建。 It seems that Azure DevOps do supports that. Azure DevOps 似乎确实支持这一点。 But there was no document nor tutorial about it.但是没有关于它的文档或教程。 How to achieve that?如何做到这一点?

You'll need to define a build validation policy for you branches (taken from Improve code quality with branch policies > Build Validation :您需要为分支定义构建验证策略(取自使用分支策略提高代码质量 > 构建验证

  • Select the build definition from the Build definition drop-down.从构建定义下拉列表中选择构建定义。
  • Choose the type of Trigger - either Automatic (whenever the source branch is updated) or Manual.选择触发器的类型 - 自动(每当更新源分支时)或手动。
  • Configure the Policy requirement.配置策略要求。 If set to Required, builds must complete successfully in order to complete pull requests.如果设置为必需,构建必须成功完成才能完成拉取请求。 Choose Optional to provide a notification of the build failure but still allow pull requests to complete.选择 Optional 以提供构建失败的通知,但仍允许拉取请求完成。
  • Set a build expiration to make sure that updates to your protected branch don't break changes in open pull requests.设置构建过期时间以确保对受保护分支的更新不会破坏开放拉取请求中的更改。
    • Immediately when branch name is updated : This option sets the build policy status in a pull request to failed when the protected branch is updated.branch name更新时立即:当受保护的分支更新时,此选项将拉取请求中的构建策略状态设置为失败。 You must requeue a build to refresh the build status.您必须重新排队构建以刷新构建状态。 This setting ensures that the changes in pull requests build successfully even as the protected branch changes.此设置可确保拉取请求中的更改即使在受保护分支发生更改时也能成功构建。 This option is best for teams that have important branches with a lower volume of changes.此选项最适合拥有重要分支且更改量较少的团队。 Teams working in busy development branches may find it disruptive to wait for a build to complete every time the protected branch is updated.在繁忙的开发分支中工作的团队可能会发现每次更新受保护分支时等待构建完成会造成破坏。
    • After n hours if branch name has been updated : This option expires the current policy status when the protected branch updates if the passing build is older than the threshold entered.如果branch name已更新,n小时:如果通过的构建早于输入的阈值,则当受保护的分支更新时,此选项将使当前策略状态过期。 This option is a compromise between always requiring a build when the protected branch updates and never requiring one.此选项是在受保护分支更新时始终需要构建和从不需要构建之间的折衷。 This choice is excellent for reducing the number of builds when your protected branch has frequent updates.当您的受保护分支频繁更新时,此选择非常适合减少构建数量。
    • Never : Updates to the protected branch do not change the policy status. Never :对受保护分支的更新不会改变策略状态。 This reduces the number of builds for your branch, but can cause problems when closing pull requests that haven't been updated recently.这会减少分支的构建数量,但在关闭最近未更新的拉取请求时可能会导致问题。
  • Choose an optional Display name for this build policy which is used to identify the policy on the Branch policies page.为此构建策略选择一个可选的显示名称,用于在分支策略页面上标识策略。 If you don't specify a display name, the build definition name is used.如果未指定显示名称,则使用构建定义名称。

Once the configuration is complete, a pull request from GitHub should trigger a build in Azure DevOps .配置完成后,来自GitHub的拉取请求应触发Azure DevOps 中的构建。

Hope it helps!希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM