【问题标题】:error in basic ci implementation in gitlab fatal: couldn't find remote refgitlab 中的基本 ci 实现错误致命:找不到远程参考
【发布时间】:2020-05-14 07:42:39
【问题描述】:

我设置了新的 gitlab docker ,然后基于 microsoft/dotnet:latest 设置了一个带有 docer 执行器的 runner docker 然后我在 gitlab 中添加了一个简单的项目,只是一个 dotnet core hello world 然后我创建一个 ci 文件如下:

image:  microsoft/dotnet:latest

stages:
  - build


variables:
  project: "ConsoleApp"

before_script:
  - "dotnet restore"

build:
  stage: build
  variables:
    build_path: "$ConsoleApp"
  script:
    - "cd $build_path"
    - "dotnet build"

然后在管道中我得到这个输出:

Preparing environment
 Running on runner-vtysysr-project-2-concurrent-0 via e189cc9d1c60...
Getting source from Git repository
00:07
 Fetching changes with git depth set to 50...
 Reinitialized existing Git repository in /builds/root/gitlabcitest/.git/
 fatal: couldn't find remote ref refs/pipelines/18
Uploading artifacts for failed job
00:06
 ERROR: Job failed: exit code 1

我搜索错误,但所有的答案都是关于有分支的项目,但我没有任何分支,只是一个简单的 hello world 项目。

【问题讨论】:

  • 我也有类似的问题。我正在使用 Gitlab 自己的 CI README。我开了一个赏金。
  • 嗨,我的问题是在运行器 docker 中的 ssh 配置中,在将 ssh 密钥添加到 docker 问题解决后
  • 好收获。我已将您的评论包含在答案中以提高知名度。
  • @alikamrani 您能否详细说明您的问题是什么以及您如何解决它

标签: docker continuous-integration gitlab-ci gitlab-ci-runner


【解决方案1】:

OP ali-kamrani 加上the comments

我的问题在 ssh config in runner docker: 在adding the ssh key to docker 之后,问题解决了。


其他途径(对于其他用户),如果这类似于gitlab-org/gitlab issue 36123

我们使用git push --mirror 定期从不同的存储库镜像一些项目。
事实证明,它还会删除未知分支,即pipelines/XXXXmerge/XXXX

我们现在正在显式推送和删除每个分支,并忽略所有 pipelines/XXXXmerge/XXXX 分支。
之后就没有再出现这个错误了。

我了解您的分支机构不多,但这里的问题不在于您当地的分支机构。
它是一个本地启动的推送操作,修剪本地不存在的远程分支。

基本上,管道取决于特定于管道的 ref refs/pipelines/*,并且它必须在管道运行时存在。
所以如果git push --mirror 删除这些 refs,你可能会遇到作业失败。

同样的问题说明了类似的情况:

在我们的设置中,我们使用系统挂钩将 GitLab 存储库镜像到另一个更靠近 GitLab Runner 实例所在的位置。
这已经运行了很长时间了。

但是,既然 GitLab 依赖于现有的 refs/pipelines/<pipeline ID> 引用,我们所有的跑步者都会失败。

问题在于refs/pipelines/<pipeline ID> ref 是在幕后创建的,并且没有调用系统挂钩(因此我们不知道需要镜像的新 ref)。
内置的 Repository Mirroring 功能不是很适合我们,因为它必须为每个存储库配置;使用 System Hooks,我们可以自动镜像我们所有的存储库。

【讨论】:

猜你喜欢
  • 2012-12-12
  • 2022-10-24
  • 1970-01-01
  • 2014-08-18
  • 1970-01-01
  • 2012-10-08
  • 2021-07-16
  • 1970-01-01
  • 2015-03-07
相关资源
最近更新 更多