Team Services文档(https://www.visualstudio.com/en-us/docs/build/define/repository#what-kinds-of-submodules-can-i-check-out)指出我可以$ git add submodule
如果
他们举了一个例子:
git submodule add /../../submodule.git mymodule
如果我在同一个项目中引用git repo,比如
git submodule add ./../other-repo mymodule
它解决了正确的回购,但希望我提供凭证。构建失败,并显示以下消息:
Cloning into 'mymodule'...
fatal: could not read Username for 'https://xxx.visualstudio.com': Invalid argument
提供带有凭据(https://user:password@xxx.visualstudio.com/..。)的完整网址有效,但IMO是一个糟糕的解决方案。
文档表明,这应该与相对网址一起使用,而不使用凭据。我错了吗?
使用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这样的子模块说 - 但要注意:VSTS git build fails with git submodule
答案 0 :(得分:1)
还请检查两个存储库的路径。如果项目中只有两个存储库,则第一个创建的存储库A的路径为:
https://xxxx.visualstudio.com/_git/A
第二个创建回购B的路径是:
https://xxxx.visualstudio.com/A/_git/B
在这种情况下,您需要使用如下的相对路径:
../../A/_git/B
答案 1 :(得分:0)
我从Submodules - Azure Repos获悉,在以下情况下存在问题:
如果您按照上述部分中的说明限制了工作访问令牌,则将无法执行此操作。
我自己只尝试过nr 1,它对我们有用。
Limit job authorization scope to referenced Azure DevOps repositories
,这将授予对所有DevOps存储库的管道访问权限。../MySubmoduleRepo
或../../../OtherProject/_git/MySubmoduleRepo
。https://stackoverflow.com/a/63593883/134761
steps:
- checkout: self
submodules: false
persistCredentials : true
- powershell: |
$header = "AUTHORIZATION: bearer $(System.AccessToken)"
git -c http.extraheader="$header" submodule sync
git -c http.extraheader="$header" submodule update --init --force --depth=1