- gitlab runner docker容器安装
安装命令:docker run -d --name gitlab-runner -v /srv/gitlab-runner/config:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest
- GitLab-CI注册Runner
(1)进入容器内部
docker exec -it -uroot gitlab-runner bash
(2)执行下列注册命令
[root@localhost ~]# gitlab-ci-multi-runner register
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://192.168.2.141:9001/ (说明:token 如下图所示)
Please enter the gitlab-ci token for this runner:
yLxk5Eaj1jYXnAJS5*** (说明:token 如下图所示)
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):
f192.168.2.107 (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):
java:latest
(说明:因为是java web项目这里,默认设为java,也可以用其他版本) Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
3. 注册完成后,项目的runner将会创建成功
4. 简单测试
项目下创建.gitlab-ci.yml ,使用模板文件进行测试runner是否可用
点击run pipeline进行测试,
若碰到以下错误:
fatal: unable to access 'http://gitlab-ci-token:xxxxxx@ip/xxx/citest.git/': Failed to connect to xx.xx.xx.xxx port 80: Connection refused
则可在/etc/gitlab-runner/config.toml文件里添加 clone_url = "xxx"