在 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 错误
最佳答案
您可以尝试检查管道的选项Checkout submodules
。请参阅以下步骤:
在 yaml 管道编辑页面上单击 3dots --> 触发器。
转到Yaml选项卡-->获取源-->检查 checkout 子模块
然后,当您运行管道时,Azure Devops 管道将自动更新子模块。
如果由于子模块存储库是私有(private)的或位于不同的组织中并且无法从 Azure Devop 管道访问而导致上述步骤无法更新子模块。您可以尝试如下配置子模块凭据。
1、设置一个管道 secret 变量来保存子模块存储库的凭据(例如PAT)。
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/