最近使用遇到一些问题:

Running with gitlab-runner 17.10.0 (67b2b2db)
  on wz-arm64-host-runner8 Q3NRHTCy, system ID: s_a7d2f872e9b4
Preparing the "shell" executor 00:00
Using Shell (bash) executor...
Preparing environment 00:00
Running on xxx-runner8...
Getting source from Git repository 00:01
Fetching changes with git depth set to 50...
重新初始化已存在的 Git 仓库于 /home/gitlab-runner/builds/Q3NRHTCy/0/cloud/xxx-top/.git/
Checking out 2356a4c2 as detached HEAD (ref is release/2.6)...
warning: 删除 xxx/xxx/xxx/xxx/xxx-1.0/Makefile 失败: 权限不够
Cleaning up project directory and file based variables 00:00
ERROR: Job failed: exit status 1

最后发现是某一级路径的所有者被改变为 root 导致无法删除,造成该现象的原因未知。通过查阅资料和文档,在 gitlab-runner 的配置文件增加一行 pre_get_sources_script 解决:

[root@wz-kylin-v10-gfb-runner8 ~]# cat /etc/gitlab-runner/config.toml 
...

[session_server]
  session_timeout = 1800

[[runners]]
  ...
  pre_get_sources_script = "sudo chown -R gitlab-runner:gitlab-runner ."
  ...

References

最后修改:2025 年 04 月 15 日
如果觉得我的文章对你有用,请随意赞赏