Gitlab Submodules sync fails on non default branch
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Problem
In a project with a multiple Sub-modules User can't synchronize them as per Using Git submodules with GitLab CI/CD when non default branch been used. I read docu and could not find any limitation.
Detection
- Create a project with multiple Submodules.
- Create
.gitmodulesfile with branches and urls, e.g.:
[submodule "config"]
path = config
url = ../../../../configuration/config.git
branch = master
[submodule "guide"]
path = guide
url = ../../../../../../../../api/guide.git
branch = release
[submodule "template"]
path = template
url = ../../../../shared/docs/templates/template.git
branch = release
[submodule "faq"]
path = faq
url = ../../../../../../all/faq.git
branch = release
[submodule "handbook"]
path = handbook
url = ../../../../../../all/handbook.git
branch = release
here master branch of config - is default branch. Other repos branches are release and they are non default branches.
- create Pipeline with e.g.:
variables:
GIT_SUBMODULE_STRATEGY: recursive
GIT_SUBMODULE_PATHS: config template faq handbook guide
GIT_SUBMODULE_UPDATE_FLAGS: --remote
- execute and see an error on all repositories with branch
release(non default)
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/GROUP/teams/TEAM/services/documentation-service/.git/
Created fresh repository.
Checking out a9040829 as detached HEAD (ref is ZeroSubmodule)...
Updating/initializing submodules recursively with git depth set to 50...
Submodule 'guide' (https://gitlab-ci-token:[MASKED]@gitlab.FQDN/api/guide.git) registered for path 'guide'
Submodule 'handbook' (https://gitlab-ci-token:[MASKED]@gitlab.FQDN/GROUP/teams/all/handbook.git) registered for path 'handbook'
Submodule 'faq' (https://gitlab-ci-token:[MASKED]@gitlab.FQDN/GROUP/teams/all/faq.git) registered for path 'faq'
Submodule 'config' (https://gitlab-ci-token:[MASKED]@gitlab.FQDN/GROUP/teams/TEAM/developer-portal/configuration/config.git) registered for path 'config'
Submodule 'template' (https://gitlab-ci-token:[MASKED]@gitlab.FQDN/GROUP/teams/TEAM/templates/template.git) registered for path 'template'
Synchronizing submodule url for 'faq'
Synchronizing submodule url for 'config'
Cloning into '/builds/GROUP/teams/TEAM/services/documentation-service/faq'...
Cloning into '/builds/GROUP/teams/TEAM/services/documentation-service/config'...
fatal: Unable to find refs/remotes/origin/release revision in submodule path 'faq'
Cleaning up project directory and file based variables 00:00
ERROR: Job failed: command terminated with exit code 1
- User has access to all repos.
Impact
Pipeline
Additional information
- If I move this logic to the
scriptsection without using gitlab itself - it works fine, but bring additional effort with steps.
variables:
GIT_SUBMODULE_STRATEGY: recursive
build_docs_site_release:
image: $MTR_DOCS_IMAGE
stage: docs_build
script:
- git submodule sync --recursive
- git submodule update --init --recursive
...
- If I set branches to
master(default branch) to all submodules - it works fine. - If I add protection to the default branch - it works fine.
- If I remove protection from the non default branch - it still does not work.
- If I set branches
releaseon submodules to default - it works fine. - Also there is similar ticket, but solution does not help.
Checklist
-
Assigned severity tags based on this guidance -
Assigned to PM and EM of groupanalytics instrumentation -
Posted link to incident in g_analyze_analytics_instrumentationand tagged both PM and EM of the group
<---- TO BE FILLED BY ASSIGNEE / RESOLUTION DRI---->
Summary
Root Cause
Resolution
Edited by 🤖 GitLab Bot 🤖