git - 为什么 Gitlab CI 无法获取 git 子模块但在随后的推送中检查出子模块?
问题描述
我的项目由一个父项目和一个子项目组成。子项目作为子模块包含在父项目中。
我正在使用 Gitlab CI。下面是 .gitlab-ci.yml 文件。
stages:
- build
variables:
GIT_SUBMODULE_STRATEGY: recursive
build-backend:
image: mcr.microsoft.com/dotnet/core/sdk:3.1
stage: build
script:
- echo "build-backend"
- apt update -y
- apt install -y nodejs npm
- node --version
- npm --version
- ls -al MyApp/client
- dotnet publish MyApp /p:PublishProfile="Profile"
gitmodules 文件看起来像这样
[submodule "MyApp/client"]
path = MyApp/client
url = ../myappclient.git
branch = master
如果我对源代码进行更改并推送到 Gitlab,那么 Gitlab 会失败并出现此错误
fatal: destination path '/builds/def/abc/xyz/MyApp/client' already exists and is not an empty directory.
完整的错误信息
Running with gitlab-runner 13.1.0 (6214287e)
on runner-docker-builder-7.dev.nsynd.com spMNyspT
Preparing the "docker" executor
00:00
Using Docker executor with image mcr.microsoft.com/dotnet/core/sdk:3.1 ...
Pulling docker image mcr.microsoft.com/dotnet/core/sdk:3.1 ...
Using docker image sha256:052ed32b57d8892af69eb4141a96032b01534ccc63db136c5649813e727c78ca for mcr.microsoft.com/dotnet/core/sdk:3.1 ...
Preparing environment
00:02
Running on runner-spmnyspt-project-440-concurrent-0 via runner-docker-builder-7.dev.nsynd.com...
Getting source from Git repository
00:04
Fetching changes...
Reinitialized existing Git repository in /builds/def/abc/xyz/.git/
Checking out b626802d as MyBranch...
Updating/initializing submodules recursively...
Synchronizing submodule url for 'MyApp/client'
fatal: destination path '/builds/def/abc/xyz/MyApp/client' already exists and is not an empty directory.
fatal: clone of 'https://gitlab-ci-token:[MASKED]@git.dfghj.com/def/abc/mysubmodule.git' into submodule path '/builds/def/abc/xyz/MyApp/client' failed
Failed to clone 'MyApp/client'. Retry scheduled
fatal: destination path '/builds/def/abc/xyz/MyApp/client' already exists and is not an empty directory.
fatal: clone of 'https://gitlab-ci-token:[MASKED]@git.dfghj.com/def/abc/mysubmodule.git' into submodule path '/builds/def/abc/xyz/MyApp/client' failed
Failed to clone 'MyApp/client' a second time, aborting
ERROR: Job failed: exit code 1
如果我推动另一个更改(任何人为的更改),那么构建工作。
- 为什么Gitlab第一次获取子模块失败?
- 我需要在最后一次构建后清理吗?
解决方案
推荐阅读
- reactjs - SVG use variables with ReactJS
- android - 我们是否需要 Play 管理中心帐户来显示 admob 横幅广告和插页式广告?
- google-api - 使用 API 和 Postman 将新域发布到 Google 日历资源
- ios - Video converted from mov to mp4 on iOS can not be played on browser etc
- azure - Setup Database Context for Entity Framework 6 using Environmental Variables
- android - 屏幕旋转时导致跳帧的片段
- javascript - Defining listener on web navigation on pages declared by user aka How to define mutable host in background.js?
- angular - 获取 Firebase Firestore 集合中最后创建的文档
- google-app-engine - 使用假登录用户测试 GAE 处理程序
- forms - 什么是真正的 HTTP 请求?