git - 保存 github 用户名以更新子模块 azure pipeline

标签 git azure github azure-pipelines

我正在尝试 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

这是一个case具有类似的问题和 document可以引用一下。

关于git - 保存 github 用户名以更新子模块 azure pipeline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64960898/

相关文章:

git - 如何恢复默认设置或使用 git diff 的 UI 工具?

c# - 使用自定义模型 Microsoft azure 的 Azure 语音到文本单词准确度(以 % 为单位)

python - 如何使用 python 运行 Azure CLI 命令?

github - TeamCity 多个 VCS 根

git - 'git cherry'是否考虑head和upstream的commit数?

git - 如何在 github 上同时测试多个 Pull-Request?

git - Azure DevOps 单个 Repo 下的多个构建管道 使用 Git 时耗尽构建服务器内存

azure - 使用突触分析管道将 Blob 文件数据插入现有 SQL 表的预复制脚本

github - 从Google云端硬盘将图像添加到GitHub Readme.md

json - OpenShift V3 : understanding the process with Docker