gitlab-runner常用命令docker版
docker-gitlab-runner
安装配置
# docker安装gitlab-runner
docker pull gitlab/gitlab-runner
# 查看版本
docker run --rm -t -i gitlab/gitlab-runner --help
# 启动并挂载
docker run --name gitlab-runner --restart always -v /usr/local/var/docker/gitlab-runner/config:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock -v /root/.m2:/root/.m2 gitlab/gitlab-runner
# 进入容器,注册runner
docker exec -it gitlab-runner /bin/bash
gitlab-runner register
# 输入gitlab服务器地址:Enter the GitLab instance URL (for example, https://gitlab.com/):
http://172.17.0.1
# Enter the registration token: 输入token,从gitlab获得
iZj2bKKef****
# Enter a description for the runner:描述,根据情况自定义
my project test
# Enter tags for the runner (comma-separated):输入标签,重要,和.gitlab-ci.yml的tag会进行关联,根据逗号隔开
dev,test
# Enter optional maintenance note for the runner: 主要说明
lcm_test
# Enter an executor: parallels, shell, ssh, virtualbox, docker+machine, docker-ssh, docker, docker-ssh+machine, kubernetes, custom: 执行器,docker最优
docker
# Enter the default Docker image (for example, ruby:2.7):设置默认的docker镜像 tico/docker 这里最好用自己建的镜像,方便挂载宿主机:172.17.0.1:5000/tico/docker
tico/docker
注意,最后一步的镜像设置很重要,意味着每次的gitlab-runner会新生成一个docker镜像容器,是在这个镜像的基础上,所以,一个有基本命令的镜像是很必要的,可以用 tico/docker
修改gitlab默认host:vim /etc/gitlab/gitlab.rb
gitlab重新生效:gitlab-ctl reconfigure && gitlab-ctl restart