添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

#安装官方镜像源

[root@k8s-node02 ~]# curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash

#yum 安装gitlab Runner

[root@k8s-node02 ~]# yum install gitlab-runner  -y

[root@k8s-node02 tools]# ll total 0 [root@k8s-node02 tools]# wget https://packages.gitlab.com/runner/gitlab-runner/packages/fedora/29/gitlab-runner-12.6.0-1.x86_64.rpm/download.rpm [root@k8s-node02 tools]# ll total 49860 -rw-r--r-- 1 root root 51052604 Jan 19 22:45 gitlab-runner-12.6.0-1.x86_64.rpm

安装 gitlab runner

#安装git
[root@k8s-node02 tools]# yum install git -y
#rpm离线安装gitlab runner,需要依赖git,所以请提前安装git
[root@k8s-node02 tools]# rpm -ivh gitlab-runner-12.6.0-1.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:gitlab-runner-12.6.0-1           ################################# [100%]
  • 提示:以上两种安装,请各位安装实际情况安装
  • 指定gitlab-runner
    [root@k8s-node02 ~]# useradd staff
    [root@k8s-node02 ~]# gitlab-runner uninstall 
    Runtime platform                                    arch=amd64 os=linux pid=25137 revision=ac8e767a version=12.6.0
    [root@k8s-node02 ~]# gitlab-runner install --working-directory /home/staff --user staff
    Runtime platform                                    arch=amd64 os=linux pid=25169 revision=ac8e767a version=12.6.0
    [root@k8s-node02 staff]# vim /etc/systemd/system/gitlab-runner.service
    [root@k8s-node02 staff]# cat /etc/systemd/system/gitlab-runner.service
    [Unit]
    Description=GitLab Runner
    After=syslog.target network.target
    ConditionFileIsExecutable=/usr/lib/gitlab-runner/gitlab-runner
    [Service]
    StartLimitInterval=5
    StartLimitBurst=10
    ExecStart=/usr/lib/gitlab-runner/gitlab-runner "run" "--working-directory" "/home/staff" "--config" "/etc/gitlab-runner/config.toml" "--service" "gitlab-runner" "--syslog" "--user" "staff"
    Restart=always
    RestartSec=120
    [Install]
    WantedBy=multi-user.target
  • 启动gitlab服务
    [root@k8s-node02 ~]# systemctl  daemon-reload                            #重新加载配置
    [root@k8s-node02 tools]# /bin/systemctl start gitlab-runner                  #启动服务
    [root@k8s-node02 tools]# /bin/systemctl enable gitlab-runner             #设置开机启动
    [root@k8s-node02 tools]# /bin/systemctl restart gitlab-runner              #重启服务
  • 验证服务是否启动
    [root@k8s-node02 java_demo]# ps -ef |grep gitlab
    root     25339     1  0 01:16 ?        00:00:11 /usr/lib/gitlab-runner/gitlab-runner run --working-directory /home/staff --config /etc/gitlab-runner/config.toml --service gitlab-runner --syslog --user staff
    [root@k8s-node02 ~]# chown -R staff.staff /home/gitlab-runner

    3)gitlab runner注册服务

    安装了 gitlab Runner 之后,就可以为 gitlab 中的仓库注册一个 Runner ,注册的交互式命令如下:

    [root@k8s-node02 ~]# gitlab-runner register
  • 我们开始注册 G it Lab Projects v  Admin Area  - Overview  Dashboard  Projects  Users  Groups  Jobs  Runners  Gitaly Servers  Groups v  More v  Admin Area Runners  A 'Runner' is a process which runs ajob. You can set up as many Runners as you need.  Runners can be placed on separate users, servers, even on your local machine.  Each Runner can be in one of the following states and/or belong to one of the following  Search or jump to...  Set up a shared Runner manually  1. Install GitLab Runner  2. Specify the following URL during the Runner setup: http://1g2 . 168.230 .133/  Q  0)  types:  group  specific  Iliéck  - Runner runs jobs from all unassigned projects  Runner runs jobs from all unassigned projects in its group  - Runner runs jobs from assigned projects  Runner cannot be assigned to other projects  Runner will not receive any new jobs  f] Runners  Recent searches v  Search or filter results...  Reset runners registration token  4. Start the Runner!  Created date  token  Runners currently online: O
    [root@k8s-node02 ~]# gitlab-runner register
    Runtime platform                                    arch=amd64 os=linux pid=6245 revision=ac8e767a version=12.6.0
    Running in system-mode.                            
    #输入公司的gitlab公网地址                                                   
    Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
    http://192.168.200.133/
    #输入gitlab的token,找到第三步token,然后选择第四步,复制token
    Please enter the gitlab-ci token for this runner:
    8sjydnrsPuSRhKiQTQky
    #输入描述这个runner名称
    Please enter the gitlab-ci description for this runner:
    [k8s-node02]: my-runner
    #输入runner的标签
    Please enter the gitlab-ci tags for this runner (comma separated):
    my-tag,another-tag
    Registering runner... succeeded                     runner=8sjydnrs
    #输入runner执行器的环境
    Please enter the executor: custom, docker-ssh, parallels, kubernetes, docker-ssh+machine, docker, shell, ssh, virtualbox, docker+machine:
    shell
    Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded! 
  • 验证gitlab runner是否注册成功 G it Lab Projects v  Admin Area  - Overview  Dashboard  Projects  Users  Groups  Jobs  Runners  Gitaly Servers  Monitoring  Messages  System Hooks  Groups v  More v  Admin Area Runners  (settings)  A 'Runner' is a process which runs ajob. You can set up as many Runners as you need.  Runners can be placed on separate users, servers, even on your local machine.  Each Runner can be in one of the following states and/or belong to one of the following  types:  Search or jump to...  Set up a shared Runner manually  1. Install GitLab Runner  2. Specify the following URL during the Runner setup: http:1/192 . 168.230 .133/  3. Use the following registration token during setup: 8sjydn rspuSRhKIQTQky  Reset runners registration token  4. Start the Runner!  Q  0)  group  specific  Iliéck  - Runner runs jobs from all unassigned projects  Runner runs jobs from all unassigned projects in its group  - Runner runs jobs from assigned projects  Runner cannot be assigned to other projects  Runner will not receive any new jobs  Recent searches v Search or filter results...  Type/State  shared  Runner token  Description  my-runner  Version  12.6.o  IP Address  192.168.200.134  Created date  Projects Jabs  n/a  Tags  another-tag  my-tag  Last contact  in 5 hours  Runners currently online: 1  11
  • 在验证的时候,请刷新界面,再次查看,验证
    3)gitlab Runner常用命令汇总