Reputation: 2008
[submodule "vendor/submodules/test-sub-project"]
path = submodules/test-sub-project
url = ../../test-group-kirby/test-sub-project.git
variables:
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- apk update && apk add git
- git submodule sync --recursive
- git submodule update --init --recursive
test:
script:
- pwd
- ls -al
- ls -al ../
- ls -al ../../
... I then checked the job output ...
Running with gitlab-runner 12.3.0 (a8a019e0)
on docker-auto-scale ed2dce3a
Using Docker executor with image ruby:2.5 ...
Pulling docker image ruby:2.5 ...
Using docker image sha256:e216e233b2581d7f45d2bc2c4dce4f1f293267b29c45bfd929d038a9a67b4058 for ruby:2.5 ...
Running on runner-ed2dce3a-project-15133453-concurrent-0 via runner-ed2dce3a-srm-1572642947-b5456b44...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/test-group-kirby/test-project-1/.git/
Created fresh repository.
From https://gitlab.com/test-group-kirby/test-project-1
* [new ref] refs/pipelines/93160262 -> refs/pipelines/93160262
* [new branch] master -> origin/master
Checking out b624748a as master...
Updating/initializing submodules recursively...
$ apk update && apk add git
/bin/bash: line 89: apk: command not found
$ git submodule sync --recursive
$ git submodule update --init --recursive
$ pwd
/builds/test-group-kirby/test-project-1
$ ls -al
total 48
drwxrwxrwx. 3 root root 4096 Nov 1 21:17 .
drwxrwxrwx. 4 root root 4096 Nov 1 21:17 ..
drwxrwxrwx. 6 root root 4096 Nov 1 21:17 .git
-rw-rw-rw-. 1 root root 274 Nov 1 21:17 .gitlab-ci.yml
-rw-rw-rw-. 1 root root 141 Nov 1 21:17 .gitmodules
-rw-rw-rw-. 1 root root 18 Nov 1 21:17 README.md
$ ls -al ../
total 32
drwxrwxrwx. 4 root root 4096 Nov 1 21:17 .
drwxrwxrwx. 3 root root 4096 Nov 1 21:17 ..
drwxrwxrwx. 3 root root 4096 Nov 1 21:17 test-project-1
drwxrwxrwx. 3 root root 4096 Nov 1 21:17 test-project-1.tmp
$ ls -al ../../
total 24
drwxrwxrwx. 3 root root 4096 Nov 1 21:17 .
drwxr-xr-x. 1 root root 4096 Nov 1 21:17 ..
drwxrwxrwx. 4 root root 4096 Nov 1 21:17 test-group-kirby
Job succeeded
Question: 1. Should I expect to see a directory called vendor? 2. If so, why didn't it clone?
Upvotes: 2
Views: 6361
Reputation: 7364
It seems that you may have not added the git submodule
correctly.
In test-kirby-group/test-project-1
do the following:
.gitmodules
which was created manuallygit submodule add <git@gitlab ...> <path/to/submodule>
.gitmodules
from the above command to use a relative URL (i.e. what you already have url = ../../test-group-kirby/test-sub-project.git
), for it to work with GitLab CIbefore_script
, as long as you are using gitlab-runner
v1.10+, you only need the following in your CI script:variables:
GIT_SUBMODULE_STRATEGY: recursive
See Using Git submodules with GitLab CI for more information.
Upvotes: 5