针对需要将Github存储库之间的分支和标签同步到Azuredevops存储库这个问题,本篇文章进行了详细的解答,同时本文还将给你拓展asp.net-mvc–在存储库之间调用方法–存储库模式、Azur
针对需要将 Github 存储库之间的分支和标签同步到 Azure devops 存储库这个问题,本篇文章进行了详细的解答,同时本文还将给你拓展asp.net-mvc – 在存储库之间调用方法 – 存储库模式、Azure DevOps - Github 状态检查、Azure Devops GIthub 网络钩子、Azure DevOps 管道 - 从其他存储库获取分支等相关知识,希望可以帮助到你。
本文目录一览:- 需要将 Github 存储库之间的分支和标签同步到 Azure devops 存储库
- asp.net-mvc – 在存储库之间调用方法 – 存储库模式
- Azure DevOps - Github 状态检查
- Azure Devops GIthub 网络钩子
- Azure DevOps 管道 - 从其他存储库获取分支
需要将 Github 存储库之间的分支和标签同步到 Azure devops 存储库
如何解决需要将 Github 存储库之间的分支和标签同步到 Azure devops 存储库?
我正在从 Github 迁移到 Azure devops 存储库。 现在我已经在 Azure devops 中拥有了一个 repo,但它已经过时了,现在我需要从 Github 同步它。
也许有一些分支不在 Azure DevOps 中,还有标签。
我正在使用:
git branch -r | grep -v ''\->'' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git push https://xxxx@dev.azure.com/_git/reponame -u --all --force
但我不确定此命令是否将所有分支移动到 Azure devops。 此外,我没有看到在导入整个 Github 存储库后创建的新标签。
如何同步标签?
解决方法
我需要添加这一行并将所有标签转移到新的存储库中。
git push https://xxxx@dev.azure.com/_git/reponame -u --tags --force
asp.net-mvc – 在存储库之间调用方法 – 存储库模式
解决方法
Azure DevOps - Github 状态检查
要使用 GitHub 状态检查, 首先,为存储库创建一个管道并至少构建一次,以便将其状态发布到 GitHub,从而让 GitHub 知道管道的名称。 接下来,按照 GitHub 的文档在存储库的设置中配置受保护的分支。 您可以遵循此文档:Protected branches 如果您想使用触发器设置,我们建议您将 yaml 更改为:
- repository: repo1
type: githubenterprise
name: woohoo/repo1
endpoint: myendpoint
trigger:
branches:
include:
- test/*
pr:
branches:
include:
- '*'
Azure Devops GIthub 网络钩子
您使用哪种模型,经典编辑器构建还是 YAML 构建?
如果您使用的是 YAML 构建,我们可以选择 GitHub 作为源。
我们可以在验证您的拉取请求时指定目标分支。例如,要验证针对 master 和 release/* 的拉取请求,您可以使用以下 pr
触发器。
pr:
- master
- releases/*
如果您使用的是经典编辑器版本。我们可以选择拉取请求验证触发器并选中启用拉取请求验证复选框以启用拉取请求的构建。检查下面的图片。
我们可以参考此 doc 了解更多详情。
Azure DevOps 管道 - 从其他存储库获取分支
如何解决Azure DevOps 管道 - 从其他存储库获取分支?
我有两个存储库:
- devops - 包含管道定义
- src_project - 包含项目源
运行 Azure 管道时的默认设置,我可以在带有管道定义的存储库分支/标记之间进行选择。我想添加一个参数,我可以用它从源项目中选择一个分支。
这在 Azure 中可以通过简单的方式实现吗?我不想要,我不能在 src_project 中保留管道的定义。
在 Jenkins 中,我们使用了一种额外的方法来获取这些分支,使用共享库插件。
解决方法
您可以使用 repositories
类型的 resources
来实现:
resources:
repositories:
- repository: string # identifier (A-Z,a-z,0-9,and underscore)
type: enum # see the following "Type" topic
name: string # repository name (format depends on `type`)
ref: string # ref name to use; defaults to ''refs/heads/master''
endpoint: string # name of the service connection to use (for types that aren''t Azure Repos)
trigger: # CI trigger for this repository,no CI trigger if skipped (only works for Azure Repos)
branches:
include: [ string ] # branch names which will trigger a build
exclude: [ string ] # branch names which will not
tags:
include: [ string ] # tag names which will trigger a build
exclude: [ string ] # tag names which will not
paths:
include: [ string ] # file paths which must match to trigger a build
exclude: [ string ] # file paths which will not trigger a build
并使用 checkout
步,例如:
resources:
repositories:
- repository: MyAzureReposGitRepository # In a different organization
endpoint: MyAzureReposGitServiceConnection
type: git
name: OtherProject/MyAzureReposGitRepo
trigger:
- main
pool:
vmImage: ''ubuntu-latest''
steps:
- checkout: self
- checkout: MyAzureReposGitRepository
今天关于需要将 Github 存储库之间的分支和标签同步到 Azure devops 存储库的分享就到这里,希望大家有所收获,若想了解更多关于asp.net-mvc – 在存储库之间调用方法 – 存储库模式、Azure DevOps - Github 状态检查、Azure Devops GIthub 网络钩子、Azure DevOps 管道 - 从其他存储库获取分支等相关知识,可以在本站进行查询。
本文标签: