我目前正在开发一条天蓝色的管道。在我的主 github 存储库(存储库 A)中,我添加了另一个 github 存储库作为子模块。(回购协议B)
我的目标是使用以下 YAML 在管道开始处签出子模块:
stages:
- stage: checkout
jobs:
- job: checkout
steps:
- checkout: self
submodules: true
persistCredentials: true
Run Code Online (Sandbox Code Playgroud)
然后尝试签出子模块,但以以下错误结束:
Cloning into '/home/vsts/work/1/s/devops-scripting'...
fatal: could not read Username for 'https://github.com': terminal prompts disabled
fatal: clone of 'https://github.com/sourcerepo/devops-scripting.git' into submodule path '/home/vsts/work/1/s/devops-scripting' failed
Run Code Online (Sandbox Code Playgroud)
这似乎是使用不正确的用户/密码的问题 - 如果我推动我可以简单地使用提供的用户/密码参数,但这似乎不适用于签出。
如何通过天蓝色管道更新子模块?
团队服务文档(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
Run Code Online (Sandbox Code Playgroud)
如果我在同一个项目中引用 git 存储库,例如
git submodule add ./../other-repo mymodule
Run Code Online (Sandbox Code Playgroud)
它解决了正确的回购协议,但希望我提供凭据。构建失败并显示以下消息:
Cloning into 'mymodule'...
fatal: could not read Username for 'https://xxx.visualstudio.com': Invalid argument
Run Code Online (Sandbox Code Playgroud)
提供带有凭据的完整 URL ( https://user:password@xxx.visualstudio.com/.. ) 可以,但在我看来是一个糟糕的解决方案。
该文档建议这应该适用于相对 url 并且无需凭据。我错了吗?
使用 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 …Run Code Online (Sandbox Code Playgroud)