azure-devops - Azure Devops 管道 - 默认情况下子模块不会更新

标签 azure-devops azure-devops-self-hosted-agent

在 Azure DevOps 管道中,默认情况下不会更新子模块。

重现问题。

源代码

https://github.com/forvaidya/submodule.git
https://github.com/forvaidya/supermodule.git

除非我在管道中有以下步骤,否则更新不会发生。我希望默认情况下会发生这种情况,或者使用某些全局变量来启用/禁用它,默认值应该是true(刷新子模块)

- script: |
      git submodule deinit --all
      git submodule init
      git submodule update --remote
  displayName: 'Refresh Submodule'

在私有(private) Git 存储库中,上述步骤将不起作用,并且会出现 HTTP 错误

Azure Logs in Gist

最佳答案

您可以尝试检查管道的选项Checkout submodules。请参阅以下步骤:

在 yaml 管道编辑页面上单击 3dots --> 触发器

enter image description here

转到Yaml选项卡-->获取源-->检查 checkout 子模块

enter image description here

然后,当您运行管道时,Azure Devops 管道将自动更新子模块。

如果由于子模块存储库是私有(private)的或位于不同的组织中并且无法从 Azure Devop 管道访问而导致上述步骤无法更新子模块。您可以尝试如下配置子模块凭据。

1、设置一个管道 secret 变量来保存子模块存储库的凭据(例如PAT)。

enter image description here

2、然后将git config submodule.SubmoduleRepo.url添加到脚本任务中的git命令上方以更新子模块。

- script: |
      git submodule deinit --all
      git submodule init
      git config submodule.TestRepo.url https://$(PAT)@dev.azure.com/TestOrganization/TestProject/_git/TestRepo
      git submodule update --remote
    enabled: true

参见this thread了解更多信息。

更新:

您也可以在 yaml 中启用 checkout 子模块,请参阅 here了解更多信息。

- checkout: self
  submodules: true

关于azure-devops - Azure Devops 管道 - 默认情况下子模块不会更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62567506/

相关文章:

azure - 如何删除azure工件符号包

c# - 拉取访问被拒绝,存储库不存在或可能需要授权 : server message: insufficient_scope:authorization failed

安装了 docker 的 Azure Windows 自托管代理

Azure DevOps 托管代理无法拉取 Windows :2004

azure-devops - Azure DevOps 自托管代理,更新 Git 版本

Azure DevOps - 在 yaml 中配置两项作业,一项使用 cron 计划,第二项使用手动执行

azure - 如何知道PowerShell中是否存在特定字符串?

uwp - 使用 VSTS 任务将 UWP 应用分发到应用中心(又名移动中心)

azure - 自托管 MacOS 代理上的 DevOps 管道在 NuGet 包还原上失败,但在 Azure Pipeline 上运行