使用git子模块的VSTS git构建失败 [英] VSTS git build fails with git submodule

查看:349
本文介绍了使用git子模块的VSTS git构建失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio Team Services Project中有一个git仓库A和B.
B是一个子模块,在.gitmodules中具有以下配置:

$ p $ $ $ $ $ $ $ $ $ $ $ $ b path = somefolder / my_submodule
url = https://xxx.visualstudio.com/xxx/_git/B

如果我使用选项Repository / Checkout Submodules进行构建,则会出现以下错误:

 存储库type = TfsGit 
localPath = C:\\\\\\\
clean = False
sourceBranch = refs / heads / submoduletest
sourceVersion = 0378dd86db31e4d7bff8de86a482b3d8e72dd3ba
同步存储库:A(Git)
存储库url = https://xxx.visualstudio.com/_git/A
checkoutSubmodules = True
开始克隆
检出0378dd86db31e4d7bff8de86a482b3d8e72dd3ba到C:\\ \\\\\\'with submodules
在提交0378dd86db31e4d7bff8de86a482b3d8e72dd3ba
##时检出了分支库ref / heads / submoduletest对于存储库A的检查。[错误] LibGit2Sharp.NotFoundException:未能解析路径'C:/ a / 1 / S / XXX / somefol der / my_submodule / .git':系统找不到指定的路径。
## [错误]在LibGit2Sharp.Core.Ensure.HandleError(Int32结果)
## [错误]在LibGit2Sharp.SubmoduleCollection.Update(字符串名称,SubmoduleUpdateOptions选项)
## [错误]在Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.DoUpdateSubmodules(存储库中,Int32 maxRecursionDepth,Int32 currentRecursionDepth,字符串用户名,字符串密码,CancellationToken cancellationToken)
## [error] at Microsoft.TeamFoundation .distributedTask.Task.Internal.Core.GitHelper.UpdateSubmodules(ITaskEndpoint端点,存储库存储库,Int32 maxRecursionDepth,CancellationToken cancellationToken)
## [error] at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncAndCheckout (布尔cleanRepository,字符串sourceBranch,字符串sourceVersion,布尔checkoutSubmodules,CancellationToken cancellationToken)
## [error] at Microsoft.TeamFoundation.DistributedTask.Plugin.Build.GitSourceProvider。<> c__DisplayCl < PrepareRepositoryAsync> b__0()
## [错误] Microsoft.TeamFoundation.DistributedTask.Agent.Common.AgentExecutionTerminationException:准备存储库失败并出现异常。 ---> LibGit2Sharp.NotFoundException:无法解析路径'C:/a/1/s/xxx/somefolder/my_submodule/.git':系统找不到指定的路径。
## [错误]在LibGit2Sharp.Core.Ensure.HandleError(Int32结果)
## [错误]在LibGit2Sharp.SubmoduleCollection.Update(字符串名称,SubmoduleUpdateOptions选项)
## [错误]在Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.DoUpdateSubmodules(存储库中,Int32 maxRecursionDepth,Int32 currentRecursionDepth,字符串用户名,字符串密码,CancellationToken cancellationToken)
## [error] at Microsoft.TeamFoundation .distributedTask.Task.Internal.Core.GitHelper.UpdateSubmodules(ITaskEndpoint端点,存储库存储库,Int32 maxRecursionDepth,CancellationToken cancellationToken)
## [error] at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncAndCheckout (布尔cleanRepository,字符串sourceBranch,字符串sourceVersion,布尔checkoutSubmodules,CancellationToken cancellationToken)
## [error] at Microsoft.TeamFoundation.DistributedTask.Plugin.Build.GitSourceProvider。<> c__DisplayCl < PrepareRepositoryAsync> b__0()
## [error] ---在Microsoft.TeamFoundation.DistributedTask.Plugin.Build内部异常堆栈跟踪结束---
## [error]。 GitSourceProvider。<> c__DisplayClass3_0。< PrepareRepositoryAsync> b__0()
## [error] at System.Threading.Tasks.Task.Execute()

有趣的错误信息似乎是:

  LibGit2Sharp.NotFoundException :无法解析路径'C:/a/1/s/xxx/somefolder/my_submodule/.git'



梦幻般的文档指向一个认证问题:$ gb clone xxx / A - 在我的maschine works上递归。 b $ b https://www.visualstudio.com/en-us/ docs / build / define / repository

但是这并不涉及auth,甚至在.gitmodules中使用相对路径也不会导致不同的错误消息。

b
$ b

任何想法?

更新1



分店。我将更改(添加子模块)合并到master并重试 - 现在出现以下错误:

  ## [error] LibGit2Sharp。 NotFoundException:找不到对象 - 没有匹配的松散对象(4fa408bc7b29e87b7032e0f78998516ff4a4da00)

这个散列是我的子模块的HEAD - 清晰可用。

解决方案

@ eddie-msft对他的评论是正确的:在master上有一个同名的文件夹。结帐到我的测试分支没有删除该文件夹。虽然这在我在本地执行的时候起作用,但VS Team Serivices似乎有问题。



但还有另一个问题:与文档相反,我提供了完整的网址到子模块( https://xxx.visualstudio.com/xxx/_git/B )。该文件指出我应该使用相对网址(../B或../../B--它是一个猜谜游戏),但无效。


I have a git repos A and B in a Visual Studio Team Services Project. B is a submodule of A with the following config in .gitmodules:

[submodule "my_submodule"]
    path = somefolder/my_submodule
    url = https://xxx.visualstudio.com/xxx/_git/B

If I do a build with the option Repository/Checkout Submodules I get the following error:

Repository type=TfsGit
localPath=C:\a\1\s
clean=False
sourceBranch=refs/heads/submoduletest
sourceVersion=0378dd86db31e4d7bff8de86a482b3d8e72dd3ba
Syncing repository: A (Git)
repository url=https://xxx.visualstudio.com/_git/A
checkoutSubmodules=True
Starting clone
Checking out 0378dd86db31e4d7bff8de86a482b3d8e72dd3ba to C:\a\1\s with submodules
Checked out branch refs/heads/submoduletest for repository A at commit 0378dd86db31e4d7bff8de86a482b3d8e72dd3ba
##[error]LibGit2Sharp.NotFoundException: Failed to resolve path 'C:/a/1/s/xxx/somefolder/my_submodule/.git': The system cannot find the path specified.
##[error]   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
##[error]   at LibGit2Sharp.SubmoduleCollection.Update(String name, SubmoduleUpdateOptions options)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.DoUpdateSubmodules(Repository repository, Int32 maxRecursionDepth, Int32 currentRecursionDepth, String username, String password, CancellationToken cancellationToken)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.UpdateSubmodules(ITaskEndpoint endpoint, Repository repository, Int32 maxRecursionDepth, CancellationToken cancellationToken)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncAndCheckout(Boolean cleanRepository, String sourceBranch, String sourceVersion, Boolean checkoutSubmodules, CancellationToken cancellationToken)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Plugin.Build.GitSourceProvider.<>c__DisplayClass3_0.<PrepareRepositoryAsync>b__0()
##[error]Microsoft.TeamFoundation.DistributedTask.Agent.Common.AgentExecutionTerminationException: Prepare repository failed with exception. ---> LibGit2Sharp.NotFoundException: Failed to resolve path 'C:/a/1/s/xxx/somefolder/my_submodule/.git': The system cannot find the path specified.
##[error]   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
##[error]   at LibGit2Sharp.SubmoduleCollection.Update(String name, SubmoduleUpdateOptions options)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.DoUpdateSubmodules(Repository repository, Int32 maxRecursionDepth, Int32 currentRecursionDepth, String username, String password, CancellationToken cancellationToken)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.UpdateSubmodules(ITaskEndpoint endpoint, Repository repository, Int32 maxRecursionDepth, CancellationToken cancellationToken)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncAndCheckout(Boolean cleanRepository, String sourceBranch, String sourceVersion, Boolean checkoutSubmodules, CancellationToken cancellationToken)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Plugin.Build.GitSourceProvider.<>c__DisplayClass3_0.<PrepareRepositoryAsync>b__0()
##[error]   --- End of inner exception stack trace ---
##[error]   at Microsoft.TeamFoundation.DistributedTask.Plugin.Build.GitSourceProvider.<>c__DisplayClass3_0.<PrepareRepositoryAsync>b__0()
##[error]   at System.Threading.Tasks.Task.Execute()

The interesting error message seems to be:

LibGit2Sharp.NotFoundException: Failed to resolve path 'C:/a/1/s/xxx/somefolder/my_submodule/.git'

Doing a git clone xxx/A --recursive on my maschine works.

The fantastic docs point to an auth problems: https://www.visualstudio.com/en-us/docs/build/define/repository

But this says nothing about auth and even using a relative path in .gitmodules does not result in a different error message.

Any ideas?

Update 1

For testing purposes I used a branch. I merged the changes (adding submodule) to master and retried - now with the following error:

##[error]LibGit2Sharp.NotFoundException: Object not found - no matching loose object (4fa408bc7b29e87b7032e0f78998516ff4a4da00)

That hash is the HEAD of my submodule - clearly available.

解决方案

@eddie-msft was right with his comment: there was a folder with the same name on master. The checkout to my test branch did not remove the folder. While this works when I do it locally, VS Team Serivices seems to have a problem with that.

But there was another problem: Contrary to the documentation, I hat to provide the full url to the submodule (https://xxx.visualstudio.com/xxx/_git/B). The documentation states that I should use a relative url (../B or ../../B - its a guessing game) but that does not work.

这篇关于使用git子模块的VSTS git构建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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