1.安装提示:
注意:如果你打算通过gitlab-ci,将项目部署到“目标服务器”上,那么这个GitLab Runner就要提前安装到这个“目标服务器”上
(这里我们安装到服务器192.168.1.63上)
2.添加GitLab Runner yum源
curl -L <https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh> | sudo bash
3.安装GitLab Runner:
yum install gitlab-ci-multi-runner
4.向GitLab-CI注册Runner
提示:即让Runner与GitLab-CI建立联系,告诉GitLab-CI你有啥需要部署到我所在服务器的就告诉我一声我来给你在这台服务器上执行
4.1 执行命令:
gitlab-ci-multi-runner register
按以下依次提示输入相关值即可>
[root@localhost ~]# gitlab-ci-multi-runner register
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://192.168.1.60:8090/ (说明:url参考4.2 附录A获取)
Please enter the gitlab-ci token for this runner:
yLxk5Eaj1jYXnAJS5*** (说明:token参考4.2 附录A获取)
Please enter the gitlab-ci description for this runner:
[localhost.localdomain]: focus-runner-des (runner的描述名称,随便DIY能有效区分就行)
Please enter the gitlab-ci tags for this runner (comma separated):
focus-runner-tags (runner的tags名称,随便DIY能有效区分就行)
Whether to run untagged builds [true/false]:
[false]: false
(说明:将来runner被执行时,如果构建文件没有tags标记是否允许执行这个runner,一般选false,可根据需要选择)
Whether to lock Runner to current project [true/false]:
[false]: true (说明:是否锁定这个runner为这个项目所用)
Please enter the executor: docker-ssh, parallels, ssh, virtualbox, kubernetes, docker, shell, docker+machine, docker-ssh+machine:
docker (因为使用docker 所以选择docker)
Please enter the default Docker image (e.g. ruby:2.1):
node:14.16.0
(说明:因为是node项目这里,默认设为node,也可以用其他版本) Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
-------------------------- >
~~至此一个Runner已经安装完毕
已经创建好的该项目的runner
查看runner所在主机上有哪些runner是活着的:
gitlab-runner verify
如果发现runner不是活着的可以启动runner服务
执行 sudo gitlab-runner run
(说明:runner注册之后默认是自动启动的,但如果这个runner没有启动则你的pipeline在后续执行runner时将一直处于pending状态。)
卸载:gitlab-runner
sudo yum remove gitlab-runner
4.2 附录A(URL及token获取位置)
浏览器访问服务器192.168.1.60(即gitlab-ci所在服务器)的指定项目主页:
http://192.168.1.60:8090/root/test-ci
点击 Expand(展开),会看到url跟token: