Gitlab runner 13.1.1 检查提交而不是我的分支

问题描述 投票:0回答:2

我有一个 .gitlab-ci.yml 文件,之前在 Gitlab runner 12.9.0 上运行时没有出现问题。 运行程序已更新到 13.1.1,现在它不再签出到我的分支

20-branchname
,而是提交。 (可能是最新的)这意味着运行程序无法将分支与主分支合并以执行一致性检查,因为它会导致
fatal: refusing to merge unrelated histories
。我正在使用 GitLab 13.2.0-pre

当我让跑步者执行

git status
时,它会打印出 HEAD 已分离。 我发现使用不同版本的运行器的两个管道的原始日志存在差异:

12.9.0:

[32;1mChecking out 16b0a39c as 20-branchname...[0;m
From {repository url}
 * [new ref]         refs/pipelines/127602838 -> refs/pipelines/127602838
 * [new branch]      20-branchname             -> origin/20-branchname
git-lfs/2.8.0 (GitHub; windows amd64; go 1.12.2; git 30af66bb)

13.1.1:

[32;1mChecking out 7410f5aa as 20-branchname...[0;m
git-lfs/2.8.0 (GitHub; windows amd64; go 1.12.2; git 30af66bb)

这就是我的

.gitlab-ci.yml
的样子:

.shared_windows_runners:
  tags:
  - shared-windows
  - windows
  - windows-1809

stages:
  - test

# A few templates that help determine when to run a program
.template_manual_trigger_on_wip_merge_request:
  rules: &manual_trigger_on_wip_merge_request
    - if: '$CI_MERGE_REQUEST_TITLE =~ /WIP/'
      when: manual
      allow_failure: false
    - when: always
      allow_failure: false

.template_run_always:
  rules: &run_always
    - when: always
      allow_failure: false

# Check that the checked in target matches what is being generated.
Coherence Check:
  extends:
  - .shared_windows_runners
  stage: test
  rules: *manual_trigger_on_wip_merge_request
  before_script:
      # Git setup
    - git config --global user.email "[email protected]"
    - git config --global user.name "Runner name"
    - git config --global core.safecrlf false
    - git submodule sync
    - git submodule update --init
    - git status
    # Results in detached HEAD
  script:
    - git fetch origin
    - git merge origin/master -X ours -m "coherence check merge"
    # It fails here with "fatal: refusing to merge unrelated histories"

我还尝试在

git checkout 20-branchname
中添加
.gitlab-ci.yml
,虽然它确实导致
git status
显示我的分支已被签出而不是提交,但当它尝试执行以下操作时,它仍然会导致不相关的历史记录错误与主人合并。

有人知道 Gitlab 运行程序 12.9.0 和 13.1.1 之间的差异可能是原因吗?如有任何帮助,我们将不胜感激!

git gitlab branch gitlab-ci gitlab-ci-runner
2个回答
2
投票

事实证明问题出在 git 深度上。默认情况下它设置为 50,而我最近对我的分支的提交超过了 50 次。我通过将其添加到

.gitlab-ci.yml
来解决它:

variables:
  GIT_DEPTH: full

0
投票

这是正常的,gitlab始终处于分离状态。有关更多信息,请参阅此问题和答案:https://stackoverflow.com/a/78419006/773113

GIT_DEPTH 不执行任何操作来修复分离状态。也许 GIT_DEPTH 可以帮助您解决“不相关的历史记录”错误,但话又说回来,让运行程序“将分支与主分支合并”“以执行一致性检查”(无论这意味着什么)是 gitlab 的一种相当非正统的使用。

© www.soinside.com 2019 - 2024. All rights reserved.