.gitlab-ci.yml 语法错误导致 runner 报错“expected shallow list”

报错信息:

Running with gitlab-runner 15.11.0 (xxx)
  on gitrunnr xxx, system ID: s_xxx
Preparing the "shell" executor 00:00
Preparing environment 00:00
Getting source from Git repository 00:01
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /home/gitlab-runner/builds/xxx/0/xxx/test/.git/
fatal: git fetch-pack: expected shallow list
fatal: The remote end hung up unexpectedly
ERROR: Job failed: exit status 1

错误的 .gitlab-ci.yml 示例:

test-this-proj:
  stage: test
  script:
    - echo "${HOSTNAME} Running tests..."
# 此处如果有空行 或者 “#注释”,可绕过gitlab的yaml语法检查,导致runner报错
  tags:
  - shell #缩进错误
  when: always

如果仍不能解决,可以尝试将git拉取策略改为clone:

image

image

posted @ 2023-05-18 10:16  M1927  阅读(351)  评论(0编辑  收藏  举报