基于gitlab ci 进行自动化构建,当发起 merge_requests请求出发构建时job运行报错,官方推荐升级gitlab-runner 版本,版本升级后运行构建依然货报错,报错内容如下:
Running with gitlab-runner 11.10.1 (1f513601)
on jp.ptmind.com 0ea06a67
Using 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 list
fatal: The remote end hung up unexpectedly
ERROR: 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。
升级步骤如下:
删除旧版本git
yum remove git -y
安装3方yum 源,centos7 基础仓库,提供的 git 版本只有到 1.8.3,沒办法使用 git 2 的一些新功能
yum install https://centos7.iuscommunity.org/ius-release.rpm
安装新版本git
yum install git2u -y
验证版本
git --version
重新安装runner
yum install gitlab-runner -y
vi /etc/systemd/system/gitlab-runner.service
ExecStart=/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"
重新注册runner
gitlab-runner register
启动runner服务
systemctl daemon-reload
systemctl start gitlab-runner
###参考资料:
https://gitlab.com/gitlab-org/gitlab-ce/issues/60466
原文:https://blog.51cto.com/michaelkang/2387223