Fetching multiple TFS git repo sources with git submodules

怎甘沉沦 提交于 2021-01-28 19:17:36

问题


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

回答1:


You must select the option to download submodules.

In YAML you must add an explicit checkout step

steps:
- checkout: self
  submodules: true



回答2:


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.


来源:https://stackoverflow.com/questions/64197332/fetching-multiple-tfs-git-repo-sources-with-git-submodules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!