使用git子模块获取多个TFS git repo源 [英] Fetching multiple TFS git repo sources with git submodules

查看:52
本文介绍了使用git子模块获取多个TFS git repo源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我有2个存储库Test1&Test2-

  • 现在我的test2存储库中有一个.gitmodules文件和一个test1文件
  • 创建管道并选择"Checkout子模块"选项.
  • 运行管道后,我可以看到以下日志.
  • I'm facing an issue while trying to access different git sources in TFS Build.

    I have 2 repos Test1 & Test2 - https://tfs.org.com:8080/tfs/collection/project/_git/Test1 (& Test2). Under Test2, I added a sample.txt & .gitmodules file.

    .GitModules file has a cmd - git submodule add https://tfs.org.com:8080/tfs/collection/project/_git/Test1 (Since I want to checkout Test1 contents too while triggering Test2 repo)

    Now in Build def (which builds Test2) I checked the option (Checkout Submodules) - and triggered the build. But I don't see Test1's content was checkout in build server. How can I achieve this ?

    Note: I have tried with other option that I found online - but no luck.

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

    (The above one is a POC's that I'm testing to make it work in our actual environment, i.e, Azure DevOps - accessing TFS with OtherGit service connection to build and release)

    Here is the build Log for 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
    

    解决方案

    I followed the steps below and it worked as expected:

    1. Create two repositories and initialize.
    2. Use "git submodule add" command.
    3. Now I have a .gitmodules file and a test1 file in my test2 repository
    4. Create a pipeline and select the "Checkout submodules" option.
    5. I can see the following logs after running pipelines.

    这篇关于使用git子模块获取多个TFS git repo源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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