[英]How to get gitlab-ci to checkout my submodule?
我正在嘗試在 Gitlab CI 中配置自動構建。
我的項目有一個 git 子模塊。
我正在使用 Linux docker 容器運行器。
Gitlab 檢出子模塊失敗。
這是 my.gitlab-ci.yml 文件。
stages:
- build
variables:
GIT_SUBMODULE_STRATEGY: recursive
build-backend:
image: mcr.microsoft.com/dotnet/core/sdk:3.1
stage: build
script:
- dotnet publish MyWebApp /p:PublishProfile="MyPublishProfile" /p:Password=1234
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
expire_in: 1 day
paths:
- MyWebApp/bin/Release
這里的.gitmodules文件
[submodule "MyWebApp/client"]
path = MyWebApp/client
url = git@git.mycompany.abc:company/client/myclient.git
branch = qa
錯誤消息包含此行
error: cannot run ssh: No such file or directory
gitlab 中的完整錯誤消息
Running with gitlab-runner 13.1.0 (6214287e)
on runner-docker-builder-5.dev.nsynd.com t8cc1Yme
section_start:1596467453:prepare_executor
Preparing the "docker" executor
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:abc123 for mcr.microsoft.com/dotnet/core/sdk:3.1 ...
section_end:1596467453:prepare_executor
section_start:1596467453:prepare_script
Preparing environment
Running on runner-t8cc1yme-project-440-concurrent-0 via runner-docker-builder-5.dev.nsynd.com...
section_end:1596467456:prepare_script
section_start:1596467456:get_sources
Getting source from Git repository
Fetching changes...
Reinitialized existing Git repository in /builds/company/client/MyWebApp/.git/
Checking out 0a9dd30c as qa...
Updating/initializing submodules recursively...
Synchronizing submodule url for 'MyWebApp/client'
Cloning into '/builds/company/client/MyWebApp/client'...
error: cannot run ssh: No such file or directory
fatal: unable to fork
fatal: clone of 'git@git.mycompany.abc:company/client/myclient.git' into submodule path '/builds/company/client/MyWebApp/client' failed
Failed to clone 'MyWebApp/client'. Retry scheduled
Cloning into '/builds/company/client/MyWebApp/client'...
error: cannot run ssh: No such file or directory
fatal: unable to fork
fatal: clone of 'git@git.mycompany.abc:company/client/myclient.git' into submodule path '/builds/company/client/MyWebApp/client' failed
Failed to clone 'MyWebApp/client' a second time, aborting
section_end:1596467459:get_sources
ERROR: Job failed: exit code 1
在父項目 (MyWebApp) 和子模塊 (MyWebApp/client) 中,我都沒有配置部署密鑰和部署令牌。
Git 克隆不會自動克隆子模塊。 您需要執行顯式Git 初始化和更新以引入子模塊代碼。
git clone https://github.com/cameronmcnz/surface.git
git submodule init
git submodule update
我不確定您是否可以將其用於 GitLab 的 YAML 文件。
請注意, Git 初始化和更新不會為您提供子模塊的最新代碼,而是您將獲得映射到父 Git 存儲庫提交的子模塊的版本/提交。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.