本文共 2105 字,大约阅读时间需要 7 分钟。
Gitlab-runner 构建失败问题排查:
基于gitlab ci 进行自动化构建,当发起 merge_requests请求出发构建时job运行报错,官方推荐升级gitlab-runner 版本,版本升级后运行构建依然货报错,报错内容如下:
Running with gitlab-runner 11.10.1 (1f513601) on jp.ptmind.com 0ea06a67Using Shell executor...Running on jp.ptmind.com...Reinitialized existing Git repository in /data/builds/0ea06a67/0/。。。backend/.git/Fetching changes with git depth set to 10...fatal: git fetch-pack: expected shallow listfatal: The remote end hung up unexpectedlyERROR: Job failed: exit status 1
以上配置修改后,首次出发构建可以成功,再次执行merge_requests 再次触发构建,还是会报错,问题未解决;
build:common: stage: build tags: - python3 script: - cp src/requirements_shared.txt src/common/requirements.txt。。。。。。。。。。。 only: refs: - develop - staging - master - merge_requests changes: - src/common/**/*
build:common: stage: build tags: - python3 script: - cp src/requirements_shared.txt src/common/requirements.txt。。。。。。。。。。。 only: - merge_requests changes: - src/common/**/*
再次执行构建,构建构建变成偶尔会失败,点击重试能成功 。。。。。
注意此时会把gitlab-runner 也删掉,建议现在gitlab 管理平台删除runner,版本升级后在重新添加runner。
升级步骤如下:删除旧版本gityum remove git -y安装3方yum 源,centos7 基础仓库,提供的 git 版本只有到 1.8.3,沒办法使用 git 2 的一些新功能yum install https://centos7.iuscommunity.org/ius-release.rpm安装新版本gityum install git2u -y验证版本git --version重新安装runneryum install gitlab-runner -y
vi /etc/systemd/system/gitlab-runner.serviceExecStart=/usr/lib/gitlab-runner/gitlab-runner "run" "--working-directory" "/home/gitlab-runner" "--config" "/etc/gitlab-runner/config.toml" "--service" "gitlab-runner" "--syslog" "--user" "gitlab-runner"改为:ExecStart=/usr/lib/gitlab-runner/gitlab-runner "run" "--working-directory" "/data/gitlab-runner" "--config" "/etc/gitlab-runner/config.toml" "--service" "gitlab-runner" "--syslog" "--user" "root"
重新注册runnergitlab-runner register启动runner服务systemctl daemon-reloadsystemctl start gitlab-runner
###参考资料:
转载于:https://blog.51cto.com/michaelkang/2387223