在 Azure 管道中获取源代码时,如何指定从特定分支检出子模块?

When getting my source in an Azure pipeline, how do I specify submodules get checked out from a specific branch?

我们有一个 Azure 管道,我们在其中指定当“获取源代码”任务为 运行 ...

时应检出子模块

我们正在从特定分支(名为“开发”)获取源代码。如何指定我希望命名的子模块也从此分支签出?现在,子模块似乎默认到 master 分支。

Azure devops 目前没有子模块的分支过滤器选项。但是,您可以使用 git 命令轻松检出特定的子模块分支。见下文:

首先,选中 Checkout submodules 选项让您的管道检查子模块,就像您在上面的屏幕截图中所做的那样。

其次,在 git 命令下面的 运行 添加脚本任务。您可以手动签出子模块的特定分支:

cd SubmoduleFolder  #go in the submodule repo folder
git checkout $(Build.SourceBranchName)  #check out submodule branch.