问题描述

默认的 GitLab 的 Runner 在构建时不会去拉取 Git Submodules 仓库,将会提示 Skipping Git submodules setup 跳过初始化 Git Submodule 仓库

解决方法

官方提供的文档: Using Git submodules with GitLab CI/CD

1.编辑项目下的 .gitlab-ci.yml 文件(也就是 gitlab 的 CI/CD 配置文件),加入拉取子模块的配置即可!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
stages:          # List of stages for jobs, and their order of execution
# - build
# - test
- deploy

# build-job: # This job runs in the build stage, which runs first.
# stage: build
# script:
# - echo "Compiling the code..."
# - echo "Compile complete."

# unit-test-job: # This job runs in the test stage.
# stage: test # It only starts when the job in the build stage completes successfully.
# script:
# - echo "Running unit tests... This will take about 60 seconds."
# - sleep 10
# - echo "Code coverage is 90%"

# lint-test-job: # This job also runs in the test stage.
# stage: test # It can run at the same time as unit-test-job (in parallel).
# script:
# - echo "Linting code... This will take about 10 seconds."
# - sleep 10
# - echo "No lint issues found."

deploy-job: # This job runs in the deploy stage.
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
environment: production
script:
- echo "Deploying application..."
- echo "Application successfully deployed."
- /home/gitlab-runner/dep.sh

# 拉取 Submodule 内容
variables:
GIT_SUBMODULE_STRATEGY: recursive

2.将修改后的 .gitlab-ci.yml 文件推送到 gitlab ,就 OK 了!