【问题标题】:Fetching multiple TFS git repo sources with git submodules使用 git 子模块获取多个 TFS git repo 源
【发布时间】:2021-01-19 15:40:01
【问题描述】:

我在尝试访问 TFS Build 中的不同 git 源时遇到问题。

我有 2 个 repos Test1 & Test2 - https://tfs.org.com:8080/tfs/collection/project/_git/Test1 (& Test2)。在 Test2 下,我添加了一个 sample.txt & .gitmodules 文件。

.GitModules 文件有一个 cmd - git submodule add https://tfs.org.com:8080/tfs/collection/project/_git/Test1 (因为我想在触发 Test2 回购时也检查 Test1 的内容)

现在在 Build def(构建 Test2)中,我检查了选项(Checkout Submodules) - 并触发了构建。但我没有看到 Test1 的内容是在构建服务器中结帐。我怎样才能做到这一点?

注意:我已尝试使用在网上找到的其他选项 - 但没有运气。

[submodule "Test1"]
    path = Test1
    url = https://tfs.org.com:8080/tfs/collection/project/_git/Test1

(以上是我正在测试的POC,以使其在我们的实际环境中工作,即Azure DevOps - 使用OtherGit服务连接访问TFS以构建和发布)

这里是 Get Sources 的构建日志:

2020-10-04T15:16:20.1648800Z Entering TfsGitSourceProvider.PrepareRepositoryAsync
 
2020-10-04T15:16:20.1648800Z localPath=E:\Temp\1\s
 
2020-10-04T15:16:20.1648800Z clean=True
 
2020-10-04T15:16:20.1648800Z sourceBranch=refs/heads/master
 
2020-10-04T15:16:20.1648800Z sourceVersion=1cca491d4af9def54e8e9d11b3c6ffbb226ace21
 
2020-10-04T15:16:20.1648800Z Syncing repository: Test2 (Git)
 
2020-10-04T15:16:20.1648800Z repository url=https://tfs.org.com:8080/tfs/collection/project/_git/Test2
 
2020-10-04T15:16:20.1648800Z checkoutSubmodules=True
 
2020-10-04T15:16:20.2586300Z Running 'git clean -fdx' on E:\Temp\1\s.
 
2020-10-04T15:16:20.5555003Z Running 'git reset --hard HEAD' on E:\Temp\1\s.
 
2020-10-04T15:16:20.6648794Z HEAD is now at 043b897 Updated .gitmodules
 
2020-10-04T15:16:20.6805036Z Starting fetch...
 
2020-10-04T15:16:20.9930080Z Checking out 1cca491d4af9def54e8e9d11b3c6ffbb226ace21 to E:\Temp\1\s with submodules
 
2020-10-04T15:16:21.0398784Z Checked out branch refs/heads/master for repository Test2 at commit 1cca491d4af9def54e8e9d11b3c6ffbb226ace21
 
2020-10-04T15:16:21.0398784Z commit=1cca491d4af9def54e8e9d11b3c6ffbb226ace21
 
2020-10-04T15:16:21.0398784Z Leaving TfsGitSourceProvider.PrepareRepositoryAsync

【问题讨论】:

  • 你应该有一些关于你的构建的 Git 签出过程的日志。您可以将这些添加到您的问题中吗?
  • @SorenBjornstad 添加了构建日志
  • @user2153844 我对它进行了测试,但措辞很好。看起来你的步骤是正确的。你能按照我的步骤再试一次吗?
  • @user2153844 好几天没有收到您的回复,请您分享一下有关此问题的最新信息吗?如果您仍然被阻止,请随时告诉我,我会尽力提供帮助:)

标签: git tfs azure-devops


【解决方案1】:

您必须select the option 才能下载子模块。

在 YAML 中,您必须添加明确的 checkout 步骤

steps:
- checkout: self
  submodules: true

【讨论】:

  • 谢谢@giulio。但我现在正在使用 TFS Classic 构建。我们没有在 YAML 中实现。
  • 此答案的顶部屏幕截图显示了如何在 Classic 上使用它。
【解决方案2】:

我按照以下步骤操作,它按预期工作:

  1. 创建两个存储库并进行初始化。
  2. 使用“git submodule add”命令。
  3. 现在我的 test2 存储库中有一个 .gitmodules 文件和一个 test1 文件
  4. 创建一个管道并选择“Checkout submodules”选项。
  5. 运行管道后我可以看到以下日志。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-26
    • 2015-10-20
    相关资源
    最近更新 更多