Как заставить gitlab CI проверять мой подмодуль? - PullRequest
0 голосов
/ 05 августа 2020

Мое приложение состоит из бэкэнда. NET C# WebApi и интерфейса npm / node / Javascript.

У меня есть скрипт .gitlab-ci.yml. Ниже представлен файл конфигурации Gitlab CI. Я удалил ненужный текст.

stages:
 - build
build-backend:
  image: mcr.microsoft.com/dotnet/core/sdk:3.1
  stage: build
  script:
    - echo "build-backend"
    - dotnet clean WebApiServer --configuration Release
    - dotnet build WebApiServer --configuration Release    
  artifacts:
    name: "Backend-${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
    expire_in: 1 day
    paths:
      - WebApiServer/bin/Release  
build-frontend:
  image: node:12
  stage: build
  script:
    - echo "build-frontend"
    - git submodule init
    - git submodule update
    - cd WebApiServer/client
    - npm install
    - node node_modules/webpack/bin/webpack.js --env=prod --progress --profile --config=webpack.prod.js  
  artifacts:
    name: "Frontend-${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
    paths:
      - build
    expire_in: 1 day

Серверная часть строится правильно.

Но интерфейс выдает ошибку. Кажется, что gitlab не может проверить подмодуль. Хотя подмодуль размещен на том же сервере gitlab, что и бэкэнд.

$ git submodule init
$ git submodule update
Cloning into '/builds/subcompany/clientname/WebApiServer/WebApiServer/client'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@git.company.ab:subcompany/clientname/WebApiServerclient.git' into submodule path '/builds/subcompany/clientname/WebApiServer/WebApiServer/client' failed
Failed to clone 'WebApiServer/client'. Retry scheduled
Cloning into '/builds/subcompany/clientname/WebApiServer/WebApiServer/client'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@git.company.ab:subcompany/clientname/WebApiServerclient.git' into submodule path '/builds/subcompany/clientname/WebApiServer/WebApiServer/client' failed
Failed to clone 'WebApiServer/client' a second time, aborting
ERROR: Job failed: exit code 1

.gitmodules

[submodule "WebApiServer/client"]
    path = WebApiServer/client
    url = git@git.company.ab:subcompany/clientcompany/client.git
    branch = development

Вопросы

  1. Как получить gitlab для оформления заказа подмодуль?
  2. В gitmodules следует использовать URL-адрес типа S SH или URL-адрес типа HTTPS?

Обновить

Я пробовал GIT_SUBMODULE_STRATEGY: recursive. Я бы предпочел не использовать GIT_SUBMODULE_STRATEGY: recursive.

Сообщение об ошибке при использовании GIT_SUBMODULE_STRATEGY: recursive

Synchronizing submodule url for 'WebApiServer/client'
17Cloning into '/builds/subcompany/clientname/WebApiServer/WebApiServer/client'...
18error: cannot run ssh: No such file or directory
19fatal: unable to fork
20fatal: clone of 'git@git.company.ab:subcompany/clientname/client.git' into submodule path '/builds/subcompany/clientname/WebApiServer/WebApiServer/client' failed
21Failed to clone 'WebApiServer/client'. Retry scheduled
22Cloning into '/builds/subcompany/clientname/WebApiServer/WebApiServer/client'...
23error: cannot run ssh: No such file or directory
24fatal: unable to fork
25fatal: clone of 'git@git.company.ab:subcompany/clientname/client.git' into submodule path '/builds/subcompany/clientname/WebApiServer/WebApiServer/client' failed
26Failed to clone 'WebApiServer/client' a second time, aborting
28ERROR: Job failed: exit code 1.
...