[英]How to specify the submodule branch in gitlab-ci?
如何在.gitlab-ci.yml中为gitlab-ci中的子模块(不同的仓库)指定分支?
你不知道 您可以在正在构建的项目的.gitmodules
文件中指定它。
[submodule "MyRepo"]
path = MyRepo
url = https://github.com/vendor/MyRepo.git
branch = master
连同@stefan对这个问题的回答。 您还必须告诉Git仅查看指定的分支以获取最新的提交。 git submodule update
似乎总是获取最新的提交,而不管分支是什么。 进行git submodule update --remote
似乎迫使git专注于您在.gitmodules
文件中指定的分支。
因此,在您的.gitmodules
文件中,如@stefen所述:
[submodule "MyRepo"]
path = MyRepo
url = https://github.com/vendor/MyRepo.git
branch = master
然后,在您的GitLab .gitlab-ci.yml
文件中,您需要指定在设置子模块时仅查看配置的分支。 我的文件包含以下before_script
:
# GitLab CI provides a variable "GIT_SUBMODULE_STRATEGY" that sets up submodules automatically
# But then branch tracking doesn't work (doesn't seem to allow for specifying the --remote) flag
before_script:
- git submodule sync --recursive
- git submodule update --init --remote --recursive
根据文档,此before_script
与GIT_SUBMODULE_STRATEGY
提供的功能相同(除了我可以将--remote
标志添加到before_script
): https : --remote
混帐子模块战略
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.