从ADO repo引用GitHub repo中的外部代码 [英] Refer to the external code in GitHub repo from ADO repo

查看:84
本文介绍了从ADO repo引用GitHub repo中的外部代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个存储库-1个ADO&1个GitHub:

I have 2 repositories - 1 ADO & 1 GitHub:

ADO回购包含内部代码

ADO repo contains internal code

GitHub存储库包含外部代码

GitHub repo contains external code

我正在使用

I'm using https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops to checkout the above repositories.

我需要使用GitHub存储库中的一些代码文件来构建ADO存储库中的代码(这意味着ADO存储库中的内部代码依赖于外部代码GitHub存储库).

I need to use some code files in GitHub repo to build the code in ADO repo (meaning internal code in ADO repo has dependency to external code GitHub repo).

示例

<ADO repo>

<ADO-code-file>

<content>:

private readonly IXYZ _log = null;

<GitHub repo>

<GitHub-code-file>: IXYZ.cs

<content>:

public interface IXYZ
{
}

在ADO存储库中构建内部代码

build for internal code in ADO repo

private readonly IXYZ _log = null; 

现在失败了,因为IXYZ.cs是GitHub存储库的一部分.

is failing now because IXYZ.cs is a part of GitHub repository.

是否可以从ADO repo引用GitHub repo中的外部代码?

Is it possible to refer to the external code in GitHub repo from ADO repo?

推荐答案

它可以引用公共存储库(GitHub)作为Azure DevOps Git存储库中的子模块.

It's able to refer a public repo (GitHub) as submodule in Azure DevOps Git Repo.

选择是否要从子模块下载文件.你可以选择获取直接子模块或嵌套到任何子模块的所有子模块递归深度.如果要对子模块使用LFS,请确保请参阅有关将LFS与子模块一起使用的说明.

Select if you want to download files from submodules. You can either choose to get the immediate submodules or all submodules nested to any depth of recursion. If you want to use LFS with submodules, be sure to see the note about using LFS with submodules.

构建管道将检出您的Git子模块,只要它们是:

The build pipeline will check out your Git submodules as long as they are:

  • 未经身份验证的:未经身份验证的公共回购,不需要克隆或获取凭据.
  • 已认证:与上面指定的Git存储库包含在同一项目,GitHub组织或Bitbucket Cloud帐户中.

通过使用相对于主存储库的URL添加.例如,将签出该代码: git submodule add/../../submodule.git mymodule 不会签出此代码: git子模块add https://dev.azure.com/fabrikamfiber/_git/ConsoleApp mymodule

Added by using a URL relative to the main repository. For example, this one would be checked out: git submodule add /../../submodule.git mymodule This one would not be checked out: git submodule add https://dev.azure.com/fabrikamfiber/_git/ConsoleApp mymodule

示例供您参考:

[submodule "DBPkg"]
  path = DBPkg
  url = ../DBPkg

您还可以检查以下链接: https://stackoverflow.com/a/34618962/5391065

You could also check this link: https://stackoverflow.com/a/34618962/5391065

这篇关于从ADO repo引用GitHub repo中的外部代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆