【问题标题】:Gitlab runner has not acces to submoduleGitlab runner 无权访问子模块
【发布时间】:2020-02-10 05:16:48
【问题描述】:

我创建了一个带有子模块的新项目,并想运行一个 gitlab-ci.yml。 但是每次跑步者告诉我他无权访问或找不到该项目。 运行器是 Windows 10 系统上的共享运行器(必需)。它适用于旧项目,但不适用于新项目。

你知道我做错了什么吗?

我已经做了什么:

  • 在另一个跑步者身上测试
  • 对跑步者使用 fetch 和 clone
  • 在运行器 VM 上手动运行 git clone --recursive git@gitlab....
  • 在我当前的电脑上递归地克隆 repo 并且成功了!
  • first answer

CI 脚本:

stages:
  - build

variables:
  ARTIFACTS_OUTPUT_PATH: "./builds"
  GIT_SUBMODULE_STRATEGY: recursive

test_123:
    stage: build
    only:
        - tags
        - triggers
        - schedules
        - web
    script: 
        - some commands

    artifacts:
        paths:
          - ./builds/*
    tags:
        - windows

错误:

<!-- language: lang-sh -->
Cloning into 'C:/gitlab-runner/builds/765197b3/0/user/ttttttt'...
Submodule 'hfdg' (git@gitlab.XXXXXXXX:user/hfdg.git) registered for path 'hfdg'
Cloning into 'C:/gitlab-runner/builds/765197b3/0/user/ttttttt/hfdg'...
remote: 
remote: ========================================================================
remote: 
remote: The project you were looking for could not be found.
remote: 
remote: ========================================================================
remote: 
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@gitlab.XXXXXXXX:user/hfdg.git' into submodule path 'C:/gitlab-runner/builds/765197b3/0/user/ttttttt/hfdg' failed
Failed to clone 'hfdg'. Retry scheduled
Cloning into 'C:/gitlab-runner/builds/765197b3/0/user/ttttttt/hfdg'...
remote: 
remote: ========================================================================
remote: 
remote: The project you were looking for could not be found.
remote: 
remote: ========================================================================
remote: 
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@gitlab.XXXXXXXX:user/hfdg.git' into submodule path 'C:/gitlab-runner/builds/765197b3/0/user/ttttttt/hfdg' failed
Failed to clone 'hfdg' a second time, aborting

【问题讨论】:

    标签: gitlab gitlab-ci-runner


    【解决方案1】:

    问题是 gitlab-runner 没有分配给 subrepo。所以 Runner 没有访问 subrepo 的权限。

    【讨论】:

    • 嗨,你如何将 gitlab-runner 分配给子仓库?谢谢。
    • 在 Gitlab 中打开 sub-repo 页面,然后进入 Setting->CI/CID->Runners。在那里,您可以将 Runners 添加到项目中。