在我们的Gitlab服务器上,我有两个存储库,其中一个存储库(“ EPSILON-SDK-C”)是另一个存储库的子模块。当我在开发人员机器上本地运行gitlab-runner时
sudo gitlab-runner exec docker build_fw
gitlab-runner找不到子模块,如gitlab-runner的输出所示:
Updating/initializing submodules...
Submodule 'thirdparty/EPSILON-SDK-C' (/home/me/gitlab_repos/EPSILON-SDK-C) registered for path 'thirdparty/EPSILON-SDK-C'
fatal: repository '/home/me/gitlab_repos/EPSILON-SDK-C' does not exist
fatal: clone of '/home/me/gitlab_repos/EPSILON-SDK-C' into submodule path '/builds/0/project-0/thirdparty/EPSILON-SDK-C' failed
Failed to clone 'thirdparty/EPSILON-SDK-C'. Retry scheduled
fatal: repository '/home/me/gitlab_repos/EPSILON-SDK-C' does not exist
fatal: clone of '/home/me/gitlab_repos/EPSILON-SDK-C' into submodule path '/builds/0/project-0/thirdparty/EPSILON-SDK-C' failed
Failed to clone 'thirdparty/EPSILON-SDK-C' a second time, aborting
ERROR: Job failed: exit code 1
FATAL: exit code 1
但是,当我们的Gitlab服务器由提交触发时,Gitlab使用子模块成功构建了二进制文件,如以下Gitlab管道输出所示(为清楚起见,删除了4-5行):
Updating/initializing submodules...
Synchronizing submodule url for 'thirdparty/EPSILON-SDK-C'
Entering 'thirdparty/EPSILON-SDK-C'
(4-5 lines here removed for readabilty)
Authenticating with credentials from job payload (GitLab Registry)
问题:Gitlab定位子模块没有问题,那么本地gitlab-runner为什么找不到子模块?
我的.gitlab-ci.yml看起来像这样:
image: "gitlab.company.local:4567/me/dockerforfw:latest"
stages:
- build
build_fw:
stage: build
variables:
GIT_SUBMODULE_STRATEGY: normal
script:
- "bash bin/dorelease_linux.sh"
我的.gitmodules看起来像这样:
$ cat .gitmodules
[submodule "thirdparty/EPSILON-SDK-C"]
path = thirdparty/EPSILON-SDK-C
url = ../EPSILON-SDK-C
请注意,根据Gitlab文档的要求,子模块URL是相对的:https://docs.gitlab.com/ee/ci/git_submodules.html#configuring-the-gitmodules-file
我确实有权访问子模块存储库,因此与权限无关:
$ git submodule sync
Synchronizing submodule url for 'thirdparty/EPSILON-SDK-C'
我本地的gitlab-runner版本是12.3.0(a8a019e0),而我们的Gitlab服务器是版本GitLab Enterprise Edition 12.3.4-ee。
我尝试过的事情:
我已经尝试使用绝对子模块的绝对URL。 我也尝试在/ home / me / gitlab_repos /中保留子模块存储库的本地克隆 我还尝试添加以下before_script动作:
before_script:
- git submodule sync --recursive
- git submodule update --init --recursive
(更新:为了清楚起见,我已经编辑了问题)
答案 0 :(得分:2)
我想我对此有一些见识,因为我现在正在遇到这个问题。
在gitlab上,我有:
group1/proj1
group1/proj2
与此.gitsubmodules
中的proj1
[submodule "proj2"]
path = proj2
url = ../proj2.git
我尝试跑步
> C:\code\proj1>gitlabrunner.exe exec shell build_proj1 --shell powershell
但是得到了
fatal: clone of 'c:\code/proj2.git' into submodule path 'C:/code/proj1/builds/0/project-0/proj2' failed
Failed to clone 'proj2'. Retry scheduled
Cloning into 'C:/code/proj1/builds/0/project-0/proj2'...
fatal: 'c:\code/proj2.git' does not appear to be a git repository
fatal: Could not read from remote repository.
我意识到:
1.我没有proj2
本地克隆的
2.尾随.git
所以我确保回购实际上在本地存在
> cd c:\code
> git clone git@gitlab...com:group1/proj2.git
> cd proj2
> pwd
C:\code\proj2
AND
删除后缀.gitsubmodules
中的'.git'
[submodule "proj2"]
path = proj2
url = ../proj2
瞧,现在> C:\code\proj1>gitlabrunner.exe exec shell build_proj1 --shell powershell
可以正确找到..\proj2
> c:\code\proj1>C:\gitlab\gitlab-runner-windows-amd64.exe -v
Version: 12.6.0
Git revision: ac8e767a
Git branch: 12-6-stable
GO version: go1.13.4
Built: 2019-12-22T11:55:34+0000
OS/Arch: windows/amd64