我正在尝试 checkout 我的 azure 管道中的子模块。
子模块已通过以下方式添加:
git submodule add <myrepo>
并推送到主存储库。
我现在需要在管道执行期间检查此存储库,我正在使用以下代码执行此操作:
jobs:
- job: checkoutSubmodule
steps:
- checkout: self
submodules: true
这会导致抛出以下错误:
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/hkelly999/devops-scripting.git' into submodule path '/home/vsts/work/1/s/devops-scripting' failed
Failed to clone 'devops-scripting'. Retry scheduled
如何配置 pipieline 来记住我的 github 用户名?我已经尝试过了
git config --global user.name "myusername"
然而,这似乎只适用于推送提交,而不是当我尝试更新子模块时。
我如何在管道中输入用户名,或者让管道记住我的 github 用户?
最佳答案
对于私有(private)项目,azure devops 构建虚拟机无权克隆您的子模块。为了授予其克隆权限,您可以添加用户名和密码,或者将个人访问 token (PAT) 添加到 Azure devops 上的存储库中的 .gitmodules
文件中的 URL。
您需要将网址更改为https://{yourPAT}@github.com/xxx/yyy.git
.gitmodules
文件如下所示:
[submodule "DbConnector"]
path = DbConnector
url = https://{yourPAT}@github.com/xxx/xxxx
关于git - 保存 github 用户名以更新子模块 azure pipeline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64960898/