【发布时间】:2016-08-04 09:50:34
【问题描述】:
Team Services 文档 (https://www.visualstudio.com/en-us/docs/build/define/repository#what-kinds-of-submodules-can-i-check-out) 指出我可以执行 $ git add submodule if
- 它是一个直接子模块
- 未经身份验证(不适用)
- 已通过身份验证
- 包含在同一个团队项目中
- 使用主存储库中的相对 url 添加
他们举了一个例子:
git submodule add /../../submodule.git mymodule
如果我在同一个项目中引用一个 git repo,比如
git submodule add ./../other-repo mymodule
它解析了正确的 repo,但希望我提供凭据。构建失败并显示以下消息:
Cloning into 'mymodule'...
fatal: could not read Username for 'https://xxx.visualstudio.com': Invalid argument
提供带有凭据 (https://user:password@xxx.visualstudio.com/...) 的完整 URL 是可行的,但 IMO 是一个糟糕的解决方案。
文档建议这应该使用相对 url 而无需凭据。我错了吗?
编辑 1:
使用 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
编辑 2:
我无法回答这个问题。文档有误/不清楚,我选择检查子模块,如 @eddie-msft 所说 - 但请注意:VSTS git build fails with git submodule
【问题讨论】:
-
我尝试使用命令添加 Git 子模块并将构建排队,但没有发现任何问题。您可以将“system.debug”变量设置为“true”的构建排队,然后共享整个日志吗?
-
@Eddie-MSFT 添加为编辑
-
根据日志,您正在通过“命令行”构建任务在构建过程中添加子模块存储库。您可以尝试在本地计算机上添加子模块然后推送更改吗?也请尝试使用“git submodule add ../other-repo mymodule”命令。
-
我在本地添加它并尝试在构建步骤中“git submodule update --init”,但什么也没做。使用 ../other-repo mymodule 失败并显示相同的错误消息。
-
您不需要在构建步骤中直接获取它,只需在构建定义存储库设置中选中“checkout submodule”选项即可。
标签: git azure-devops git-submodules azure-pipelines