1、准备好一台干净的CentOS 7系统
2、安装Dcoker引擎

yum install vim wget yum-utils tee -y
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum -y install docker-ce
systemctl start docker
systemctl enable docker

3、安装git

yum install -y git

4、安装gitlab-runner

curl -L --output /usr/local/bin/gitlab-runner "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64"
chmod +x /usr/local/bin/gitlab-runner
useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
gpasswd -a gitlab-runner docker
newgrp docker
gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
gitlab-runner start

5、注册

点击gitlab管理员后的概览菜单,在其中有一个runner,进入runner后在右边的内容框中开源看到两个信息,一个是gitlab的url地址,一个是密钥。这两样是在注册runner时所必须的,如下图所示: 在这里插入图片描述
准备好这两个信息后,下面接着在runner服务器上进行注册:

[root@Gitlab-Runner ~]# gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=2177 revision=5316d4ac version=14.6.0
Running in system-mode.

Enter the GitLab instance URL (for example, https://gitlab.com/):
https://gitlab.****.com/
Enter the registration token:
Kxs8**********g4rQd
Enter a description for the runner:
[Gitlab-Runner]: Gitlab-Runner for linux
Enter tags for the runner (comma-separated):
shell
Registering runner... succeeded                     runner=Kxs8YMW-
Enter an executor: docker-ssh, parallels, shell, docker+machine, docker-ssh+machine, custom, ssh, virtualbox, kubernetes, docker:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

注册好之后,在gitlab的runner页面就可以看到刚才注册的runner信息了,这里注册的tags有很多个,这是根据gitlab-ci.yml文件中需要执行的命令来设置的,这里我使用的是shell,那么在gitlab-ci.yml文件中就只能自动执行shell相关的指令。

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐