GNU / Linux 安装gitlab-runner:

其安装在与安装GitLab的位置不同的服务器上

1.下载gitlab-runner二进制可执行源文件 x86-64

sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64

2.给源文件可执行权限

sudo chmod +x /usr/local/bin/gitlab-runner

3.创建一个gitlab-runner用户

sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash

4.安装、启动

sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner

安装时可指定脚本执行用户和gitlab-runner工作目录

sudo gitlab-runner start

通过GitLab的界面获取共享或特定Runner的令牌和gitlab服务器域名

(进入gitlab项目->设置->CI/CD->Runners->Setup a specific Runner manually)

1.注册

sudo gitlab-runner register

2.根据提示输入相关配置

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com )

https://gitlab.com(输入GitLab实例URL)

Please enter the gitlab-ci token for this runner

xxx(输入runner注册令牌)

Please enter the gitlab-ci tags for this runner (comma separated):

my-tag(输入runner标签 可在gitlab的UI页面修改)

Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:

shell(输入runner脚本执行环境)

注册成功后在gitlab的此项目的

设置->CI/CD->Runners页面会出现一个新的runner tag标签为刚才输入的tag标签内容