Gitlab-runner 构建失败问题排查:
1.问题起因:
基于gitlab ci 进行自动化构建,当发起 merge_requests请求出发构建时job运行报错,官方推荐升级gitlab-runner 版本,版本升级后运行构建依然会报错,报错内容如下:
##我的版本已经是最新的版本
Running with gitlab-runner 13.2.1 (efa30e33)
on 172-1xxx x8VsdjxG
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:01
Running on 172.xxxx...
Getting source from Git repository
00:02
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /home/gitlab-runner/builds/x8VsdjxG/0/PtmindDev/pe/dolxxxx/.git/
fatal: git fetch-pack: expected shallow list
fatal: The remote end hung up unexpectedly
ERROR: Job failed: exit status 1
查询相关资料,说git版本太低导致,下面进行git升级
2.先删除runner上的旧的git版本
注意此时会把gitlab-runner 也删掉,建议现在gitlab 管理平台删除runner,版本升级后在重新添加runner。
升级步骤如下:
##删除旧版本git
~]# yum remove git -y
##安装第三方yum源,centos7 基础仓库,提供的 git 版本只有到 1.8.3,沒办法使用 git 2 的一些新功能
~]# yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm
##安装最新版git 2.x
~]# yum install git
##查看版本
[root@172-19-8-115 ~]# git version
git version 2.22.0
3.重新注册runner
# For RHEL/CentOS/Fedora
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
##安装runner
~ ]# yum install gitlab-runner -y
##重新注册runner
~ ]# gitlab-runner register
Runtime platform arch=amd64 os=linux pid=6348 revision=efa30e33 version=13.2.1
Running in system-mode.
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
https://gitlab.com/
Please enter the gitlab-ci token for this runner:
xxxxxx.xxxxx.xxxx
Please enter the gitlab-ci description for this runner:
[xxx-xxx-xxx-xxx]: xxx-1xx-8x-1xx
Please enter the gitlab-ci tags for this runner (comma separated):
172-19-8-115
Registering runner... succeeded runner=gKd26wCe
Please enter the executor: custom, docker, parallels, ssh, kubernetes, docker-ssh, shell, virtualbox, docker+machine, docker-ssh+machine:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
4.再次执行CI正常运行
Running with gitlab-runner 13.2.2 (a998cacd)
on 172-19-8-115 UfHjC5ri
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:01
Running on 172-19-8-115...
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /home/gitlab-runner/builds/UfHjC5ri/0/PtmindDev/pe/dolphxxxer/.git/
Checking out db4855a6 as prod...
Removing dolphxxxxuler-alert/
Removing doxxxx-api/
Removing dolpxxxr-common/
Removing dolphinxxxr-dao/
Removing dolpxxx-dist/
Removing dolphxxx-plugin-api/
Removing dolphxxxxx-remote/
Removing dolxxxxxr-server/
Removing dolxxxx-service/
Removing dolphxxxxxxer-ui/
Removing infor
Skipping Git submodules setup
Executing "step_script" stage of the job script
$ $REGLOGIN
参考文档
https://stackoverflow.com/questions/21820715/how-to-install-latest-version-of-git-on-centos-7-x-6-x
https://blog.csdn.net/kjh2007abc/article/details/89717274
如无特殊说明,文章均为本站原创,转载请注明出处
- 转载请注明来源:Gitlab-runner 构建失败问题排查
- 本文永久链接地址:https://www.xionghaier.cn/archives/1263.html