在我们的Gitlab服务器上,我有两个repos,其中一个回购(‘EPSILON’)是另一个的子模块。当我在我的开发人员机器上本地运行gitlab- run时
sudo gitlab-runner exec docker build_fwgitlab-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运行者找不到子模块呢?
我的..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
我确实可以访问子模块repo,所以这个问题与权限无关:
$ git submodule sync
Synchronizing submodule url for 'thirdparty/EPSILON-SDK-C'我的本地Gitlab是12.3.0版本(a8a019e0),我们的GitLab服务器是GitLab企业版12.3.4-ee版本。
我尝试过的事物:
我已经尝试了ab绝对URL的子模块。我还尝试将子模块repo的本地克隆保存在/home/me/gitlab_repos/我还尝试添加以下before_script操作:
before_script:
- git submodule sync --recursive
- git submodule update --init --recursive(更新:为了清晰起见,我编辑了我的问题)
发布于 2020-01-15 21:59:23
我想我对此有一些洞察力,因为我现在正遇到这个问题。
在gitlab上我有:
group1/proj1
group1/proj2在proj1中使用此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.我意识到:
proj2 在本地克隆所以我确保回购在本地确实存在
> cd c:\code
> git clone git@gitlab...com:group1/proj2.git
> cd proj2
> pwd
C:\code\proj2和
删除 '.git‘后缀在.gitsubmodules中
[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/amd64https://stackoverflow.com/questions/58299707
复制相似问题