问题
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:
- Create two repositories and initialize.
- Use "git submodule add" command.
- Now I have a .gitmodules file and a test1 file in my test2 repository
- Create a pipeline and select the "Checkout submodules" option.
- I can see the following logs after running pipelines.
来源:https://stackoverflow.com/questions/64197332/fetching-multiple-tfs-git-repo-sources-with-git-submodules