为git子模块使用相对URL需要凭据 [英] Using relative url for git submodule needs credentials
问题描述
The Team Services documentation (https://www.visualstudio.com/en-us/docs/build/define/repository#what-kinds-of-submodules-can-i-check-out) points out that I can do a $ git add submodule
if
- 它是直接子模块
- 未经身份验证(n/a)
- 已认证
- 包含在同一团队项目中
- 使用主存储库中的相对网址添加
- it is an immediate submodule
- Unauthenticated (n/a)
- Authenticated
- Contained in the same team project
- Added by using a relative url from main repository
他们举了一个例子:
git submodule add /../../submodule.git mymodule
如果我在同一项目中引用git repo
If I reference a git repo in the same project like
git submodule add ./../other-repo mymodule
它可以解决正确的存储库,但要我提供凭据.构建失败,并显示以下消息:
It resolves the right repo but wants me to provide credentials. The build fails with the following message:
Cloning into 'mymodule'... fatal: could not read Username for 'https://xxx.visualstudio.com': Invalid argument
通过凭据提供完整的URL( https://user:password@xxx.visualstudio .com/.. .)有效,但IMO是一个不好的解决方案.
Providing the full URL with credentials (https://user:password@xxx.visualstudio.com/...) works but is IMO a bad solution.
文档建议这应该使用相对URL且没有凭据.我错了吗?
The documentation suggests that this should work with a relative url and without credentials. Am I wrong?
与system.debug一起运行:true
Running with system.debug: true
Entering OnPrepareEnvironment Primary repository: xxx Calculating build folder hash key. Loading tracking config if exists: C:\a\SourceRootMapping\07a8b96d-d805-4646-83d3-e7b2fbe394c2\18\SourceFolder.json Creating new tracking config. Loading top-level tracking config if exists: C:\a\SourceRootMapping\Mappings.json Writing config to file: C:\a\SourceRootMapping\Mappings.json Writing config to file: C:\a\SourceRootMapping\07a8b96d-d805-4646-83d3-e7b2fbe394c2\18\SourceFolder.json Checking if artifacts directory exists: C:\a\1\a Creating artifacts directory. Checking if test results directory exists: C:\a\1\TestResults Creating test results directory. Creating binaries directory. Setting local variables. Create the initial timeline records for the tasks Preparing repositories repo clean = False Found 3 endpoints to consider Found 1 repositories to sync Starting: Get sources build.fetchtags=false Entering GitSourceProvider.PrepareRepositoryAsync Repository type=TfsGit localPath=C:\a\1\s clean=False sourceBranch=refs/heads/r_080 sourceVersion=26d5a7a6e6ed47c8f12ee5dc5b376d6731b7863a Syncing repository: xxx (Git) repository url=https://xxx.visualstudio.com/_git/xxx checkoutSubmodules=False Starting clone Checking out 26d5a7a6e6ed47c8f12ee5dc5b376d6731b7863a to C:\a\1\s Checked out branch refs/heads/r_080 for repository xxx at commit 26d5a7a6e6ed47c8f12ee5dc5b376d6731b7863a Leaving GitSourceProvider.PrepareRepositoryAsync Leaving OnPrepareEnvironment Running tasks Starting task: Run git ##[warning]File name doesn't indicate a full path to a executable file. Executing the following command-line. (workingFolder = C:\a\1\s) git submodule add ./../other_repo mymodule Error message highlight pattern: Warning message highlight pattern: C:\Windows\system32\cmd.exe /c "git submodule add ./../other_repo mymodule" Cloning into 'mymodule'... Fatal: InvalidOperationException encountered. bash: /dev/tty: No such device or address error: failed to execute prompt script (exit code 1) fatal: could not read Username for 'https://xxx.visualstudio.com': Invalid argument fatal: clone of 'https://xxx.visualstudio.com/_git/other_repo' into submodule path 'mymodule' failed Finishing task: CmdLine ##[error]System.Exception: Task CmdLine failed. This caused the job to fail. Look at the logs for the task for more details. ##[error] at Microsoft.TeamFoundation.DistributedTask.Worker.JobRunner.Run(IJobContext jobContext, IJobRequest job, IJobExtension jobExtension, CancellationTokenSource tokenSource) Entering OnFinalizeJob Leaving OnFinalizeJob
我无法回答.文档是错误的/不清楚,我可以选择检出@ eddie-msft之类的子模块,但要当心:
I cannot answer this. The documentation is wrong/unclear, I went with the option to check out submodules like @eddie-msft said - but watch out: VSTS git build fails with git submodule
推荐答案
也请检查两个存储库的路径.如果您的项目中只有两个存储库,则第一个创建的存储库A的路径为:
Please also check the path of your two repositories. If you have only two repositories in your project, the path of the first created repo A would be:
https://xxxx.visualstudio.com/_git/A
第二个创建的仓库B的路径为:
And the path of the second created repo B would be:
https://xxxx.visualstudio.com/A/_git/B
在这种情况下,您需要使用如下相对路径:
In this scenario, you need to use a relative path like following:
../../A/_git/B
这篇关于为git子模块使用相对URL需要凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!