Runners 设置

使用root账号登录 gitlab

选择项目 > 设置 > CI/CD > Runners 设置
找到如下内容备用
1. 安装一个与 GitLab CI 兼容的 Runner (如需了解更多的安装信息,请查看 GitLab Runner)
2. 在 Runner 设置时指定以下 URL: http://git.dev-share.top/
3. 在安装过程中使用以下注册令牌: 1L-yXyiRzoV2a2zh9RsV
4. 启动 Runner!

Docker 镜像下载

先去 https://hub.docker.com/ 中搜索 gitlab-runner
然后找到 gitlab/gitlab-runner
两种方式下载镜像,以下两条命令都可以下载,下载的是同一资源
1、 docker pull gitlab/gitlab-runner
2、 docker pull registry.docker-cn.com/gitlab/gitlab-runner

[root@shared-server ~]# docker pull gitlab/gitlab-runner
[root@shared-server ~]#
[root@shared-server ~]# docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
gitlab/gitlab-runner   latest              bee49bb1b895        3 weeks ago         389MB
[root@shared-server ~]#

创建本地文件夹, 为了将docker程序映射到宿主机

[root@shared-server /]# cd /mnt/ && mkdir git-runner && chmod -R 777 git-runner

启动

[root@shared-server mnt]# docker run -d --name gitlab-runner --restart=always -v /mnt/git-runner:/etc/gitlab-runner bee49bb1b895
e862234be07d4704daa4f1ba780c9d7c18e43e4777b9be9715288e0d633bd7e5
[root@shared-server mnt]# docker ps -a

注册和初始化

[root@shared-server mnt]# docker exec -it gitlab-runner gitlab-ci-multi-runner register
Runtime platform                                    arch=amd64 os=linux pid=12 revision=8bb608ff version=11.7.0
Running in system-mode.

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://git.dev-share.top/ # 在gitlab Runners设置中找到

Please enter the gitlab-ci token for this runner:
1L-yXyiRzoV2a2zh9RsV # 在gitlab Runners设置中找到

Please enter the gitlab-ci description for this runner:
[e862234be07d]: msy-test msy-runner # 随便描述

Please enter the gitlab-ci tags for this runner (comma separated):
tag-test # 在配置gitlab-ci.yml 中的tags时会用到

Registering runner... succeeded                     runner=1L-yXyiR
Please enter the executor: kubernetes, parallels, docker-ssh+machine, shell, ssh, virtualbox, docker+machine, docker, docker-ssh:
shell # 选择执行哪种脚本

Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
[root@shared-server mnt]#

配置成功

回到gitlab 项目中 设置 > CI/CD > Runners 设置 可以查看runner是否配置成功


发表评论

电子邮件地址不会被公开。 必填项已用*标注