1、基础环境
docker环境、gitlab
2、gitlab-runner安装
下载:
root@ubuntu1604:~# docker pull gitlab/gitlab-runner
运行:
root@ubuntu1604:~# docker run -d --name gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock --restart always gitlab/gitlab-runner
ea6d71b9efddc7a9fce02e404818b159ef25ec3d5f610fb10d3bf579192d96ca
注册:
root@ubuntu1604:~# docker exec -it gitlab-runner gitlab-ci-multi-runner register
Runtime platform arch=amd64 os=linux pid=19 revision=e0218c92 version=14.3.2
Running in system-mode.
Enter the GitLab instance URL (for example, https://gitlab.com/):
https://xxxxxx.xxxxxxx.xxx/
Enter the registration token:
sXsENwd_UkTwjyJ2Uohd
Enter a description for the runner:
[ea6d71b9efdd]: test
Enter tags for the runner (comma-separated):
test
Registering runner... succeeded runner=sXsENwd_
Enter an executor: docker, virtualbox, docker-ssh+machine, docker+machine, kubernetes, custom, docker-ssh, parallels, shell, ssh:
docker
Enter the default Docker image (for example, ruby:2.6):
maven:latest
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
url和token,打开gitlab>项目>settings>CI/CD>Runners>Specific runners

然后刷新页面,可以看到runners,绿色为active可用。点击编辑,设置为runner job without tags,这样不受标签限制:

本文介绍了如何在Ubuntu 16.04环境下使用Docker安装GitLab Runner,并进行注册与配置。首先通过Docker拉取gitlab/gitlab-runner镜像,然后以守护进程方式运行容器并连接docker.sock。接着,使用`docker exec`命令注册Runner,指定GitLab实例URL、注册令牌和Runner描述。最后,选择docker作为Executor并设置默认Docker镜像为maven:latest。完成注册后,Runner将在GitLab中显示为active状态,可编辑配置以取消标签限制。
1万+





