相关疑难解决方法(0)

从 azure pipeline 检出 git 子模块

我目前正在开发一条天蓝色的管道。在我的主 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)

这似乎是使用不正确的用户/密码的问题 - 如果我推动我可以简单地使用提供的用户/密码参数,但这似乎不适用于签出。

如何通过天蓝色管道更新子模块?

git azure git-submodules azure-pipelines

9
推荐指数
2
解决办法
2万
查看次数

使用 git 子模块的相对 url 需要凭据

团队服务文档(https://www.visualstudio.com/en-us/docs/build/define/repository#what-kinds-of-submodules-can-i-check-out)指出我可以做一个$ git add submodule如果

  • 它是一个直接子模块
  • 未经身份验证(不适用)
  • 已认证
    • 包含在同一个团队项目中
    • 使用主存储库中的相对 url 添加

他们举了一个例子:

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 并且无需凭据。我错了吗?

编辑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 …
Run Code Online (Sandbox Code Playgroud)

git git-submodules azure-devops azure-pipelines

3
推荐指数
1
解决办法
5194
查看次数