gitlab runner安装

axing
2025-08-07 / 0 评论 / 2 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2025年08月11日,已超过12天没有更新,若内容或图片失效,请留言反馈。
安装的gitlab runner版本与gitlab版本保持一致。

一、参考文档

https://docs.gitlab.com/runner/install/index.html

二、查看gitlab版本

root@k8s-02:~# gitlab-rake gitlab:env:info

System information
System:        Ubuntu 22.04
Current User:    git
Using RVM:    no
Ruby Version:    3.2.5
Gem Version:    3.6.9
Bundler Version:2.6.5
Rake Version:    13.0.6
Redis Version:    7.2.9
Sidekiq Version:7.3.9
Go Version:    unknown

GitLab information
Version:    18.2.1
Revision:    baccadafcda
Directory:    /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:    PostgreSQL
DB Version:    16.8
URL:        http://192.168.30.181
HTTP Clone URL:    http://192.168.30.181/some-group/some-project.git
SSH Clone URL:    git@192.168.30.181:some-group/some-project.git
Using LDAP:    no
Using Omniauth:    yes
Omniauth Providers: 

GitLab Shell
Version:    14.43.0
Repository storages:
- default:     unix:/var/opt/gitlab/gitaly/gitaly.socket
GitLab Shell path:        /opt/gitlab/embedded/service/gitlab-shell

Gitaly
- default Address:     unix:/var/opt/gitlab/gitaly/gitaly.socket
- default Version:     18.2.1
- default Git Version:     2.50.1.gl1

三、yum安装

https://docs.gitlab.com/runner/install/linux-repository.html
#centos
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh" | sudo bash
#ubuntu
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash
#要安装特定版本的 GitLab Runner:
#centos
yum list gitlab-runner --showduplicates | sort -r
sudo yum install gitlab-runner-17.2.0-1
#ubuntu
apt-cache madison gitlab-runner
sudo apt install gitlab-runner=17.7.1-1 gitlab-runner-helper-images=17.7.1-1

root@k8s-02:~# gitlab-rake gitlab:env:info

System information
System:        Ubuntu 22.04
Current User:    git
Using RVM:    no
Ruby Version:    3.2.5
Gem Version:    3.6.9
Bundler Version:2.6.5
Rake Version:    13.0.6
Redis Version:    7.2.9
Sidekiq Version:7.3.9
Go Version:    unknown

GitLab information
Version:    18.2.1
Revision:    baccadafcda
Directory:    /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:    PostgreSQL
DB Version:    16.8
URL:        http://192.168.30.181
HTTP Clone URL:    http://192.168.30.181/some-group/some-project.git
SSH Clone URL:    git@192.168.30.181:some-group/some-project.git
Using LDAP:    no
Using Omniauth:    yes
Omniauth Providers: 

GitLab Shell
Version:    14.43.0
Repository storages:
- default:     unix:/var/opt/gitlab/gitaly/gitaly.socket
GitLab Shell path:        /opt/gitlab/embedded/service/gitlab-shell

Gitaly
- default Address:     unix:/var/opt/gitlab/gitaly/gitaly.socket
- default Version:     18.2.1
- default Git Version:     2.50.1.gl1
root@k8s-02:~# systemctl status gitlab
gitlab-runner.service    gitlab-runsvdir.service  gitlab.slice             
root@k8s-02:~# systemctl status gitlab
gitlab-runner.service    gitlab-runsvdir.service  gitlab.slice             
root@k8s-02:~# systemctl status gitlab-runner.service 
● gitlab-runner.service - GitLab Runner
     Loaded: loaded (/etc/systemd/system/gitlab-runner.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2025-08-11 12:31:20 UTC; 32min ago
   Main PID: 1044 (gitlab-runner)
      Tasks: 10 (limit: 23452)
     Memory: 82.6M
        CPU: 3.032s
     CGroup: /system.slice/gitlab-runner.service
             └─1044 /usr/bin/gitlab-runner run --config /etc/gitlab-runner/config.toml --working-directory /home/gitlab-runner --ser>

Aug 11 12:31:20 k8s-02 systemd[1]: Started GitLab Runner.
Aug 11 12:31:24 k8s-02 gitlab-runner[1044]: Runtime platform                                    arch=amd64 os=linux pid=1044 revisio>
Aug 11 12:31:24 k8s-02 gitlab-runner[1044]: Starting multi-runner from /etc/gitlab-runner/config.toml...  builds=0 max_builds=0
Aug 11 12:31:24 k8s-02 gitlab-runner[1044]: Running in system-mode.                           
Aug 11 12:31:24 k8s-02 gitlab-runner[1044]:                                                   
Aug 11 12:31:24 k8s-02 gitlab-runner[1044]: Usage logger disabled                               builds=0 max_builds=1
Aug 11 12:31:24 k8s-02 gitlab-runner[1044]: Configuration loaded                                builds=0 max_builds=1
Aug 11 12:31:24 k8s-02 gitlab-runner[1044]: listen_address not defined, metrics & debug endpoints disabled  builds=0 max_builds=1
Aug 11 12:31:24 k8s-02 gitlab-runner[1044]: [session_server].listen_address not defined, session endpoints disabled  builds=0 max_bu>
Aug 11 12:31:24 k8s-02 gitlab-runner[1044]: Initializing executor providers                     builds=0 max_builds=1

root@k8s-02:~# ^C
root@k8s-02:~# gitlab-runner -v
Version:      18.2.1
Git revision: cc489270
Git branch:   18-2-stable
GO version:   go1.24.4 X:cacheprog
Built:        2025-07-28T12:43:39Z
OS/Arch:      linux/amd64
如果您尝试安装的特定版本gitlab-runner而不安装相同版本的 gitlab-runner-helper-images,则可能会遇到以下错误:
sudo apt install gitlab-runner=17.7.1-1
...
The following packages have unmet dependencies:
 gitlab-runner : Depends: gitlab-runner-helper-images (= 17.7.1-1) but 17.8.3-1 is to be installed
E: Unable to correct problems, you have held broken packages.

四、rpm包安装

查找合适版本的软件包并下载

https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/yum/el7-x86_64/

[root@tiaoban gitlab-runner]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/yum/el7-x86_64/gitlab-runner-16.10.0-1.x86_64.rpm
[root@tiaoban gitlab-runner]# rpm -ivh gitlab-runner-16.10.0-1.x86_64.rpm

五、docker安装

[root@client2 docker]# mkdir gitlab-runner
[root@client2 docker]# ls
gitlab-runner
[root@client2 docker]# docker run --name gitlab-runner -itd -v /opt/docker/gitlab-runner:/etc/gitlab-runner --restart always gitlab/gitlab-runner:v16.10.0
0

评论 (0)

取消