我的项目由父项目和子项目组成。子项目作为子模块包含在父项目中。
我正在使用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
如果我推动另一个改变(任何人为的改变),那么构建工作。
发布于 2022-04-24 23:58:44
使用git clone
而不是git fetch
似乎是一种解决办法。可以在CI设置中设置它,也可以在.gitlab-ci.yml
中添加以下参数
variables:
GIT_STRATEGY: clone
https://stackoverflow.com/questions/63283906
复制相似问题