I tried a lot of different definitions of the .gitmodules but can not get the relative path for a git submodule working as part of the Gitlab CI/CD Pipeline. Both repositories are private but part of the same sub-group.
My repository structure is as follows:
- Main repository: git@code.xxx.com:GroupA/GroupB/core-solution.git
- Sub-repository to import:
git@code.xxx.com:GroupA/GroupB/devops_sc.git
I read the documentation as well as several SO posts which did not solve my problem.
.gitlab-ci.yml
stages:
- build
variables:
GIT_SUBMODULE_STRATEGY: recursive
CI_DEBUG_TRACE: "true"
GIT_STRATEGY: clone
before_script:
- apt-get update && apt-get install -y git
- git config --list
- cat .gitmodules
- ls
build:
stage: build
image: python:3.9-slim
tags: ["AWS"]
script:
- ls
.gitmodules
[submodule "devops"]
path = devops
url = ../devops_sc.git
Debugging the Pipeline shows the following. There seems to be nothing happening with these submodule commands
Checking out 85bd8213 as dev...
++ git clean -ffdx
++ git lfs version
++ git lfs pull
++ echo
++ echo 'Updating/initializing submodules recursively with git depth set to 20...'
Updating/initializing submodules recursively with git depth set to 20...
++ git submodule sync --recursive
++ git submodule foreach --recursive 'git clean -ffxd'
++ git submodule foreach --recursive 'git reset --hard'
++ git submodule update --init --recursive --depth 20
++ git submodule foreach --recursive 'git clean -ffxd'
++ git lfs version
++ git submodule foreach --recursive 'git lfs pull'
+ exit 0
Executing "step_script" stage of the job script 00:15
Output of .gitmodules inside of Pipeline execution:
$ cat .gitmodules
[submodule "devops"]
path = devops
url = ../devops_sc.git
Output of ls inside of Pipeline execution, completely missing the submodule:
++ ls
$ ls
README.md
Output of git config --list inside of Pipeline execution, missing the submodule configuration as well:
++ git config --list
$ git config --list
init.defaultbranch=none
fetch.recursesubmodules=false
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://gitlab-ci-token:[MASKED]@code.xxx.com/GroupA/GroupB/core-solution.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
If I execute git config --list locally using the absolute path inside .gitmodules then I see among other parameters:
submodule.devops.url=git@code.xxx.com:GroupA/GroupB/devops_sc.git
submodule.devops.active=true
I have no clue where to look anymore. I can’t see the error and I’m also not receiving any error message anywhere … .
Any pointers on what could be the issue?