1 部署gitlab-runner
# 先创建空的config.toml,否则启动会报错
touch /home/gitlab-runner/config.toml
version: '3'
services:
gitlab-runner:
image: gitlab/gitlab-runner:latest
privileged: true
container_name: gitlab-runner
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/gitlab-runner/config.toml:/etc/gitlab-runner/config.toml
restart: always
2 注册runner的配置
- 复制gitlab仓库URL,最后面需要有/
- 复制gitlab仓库token
- 名称,eg:runner
- 标签,eg:runner
- 运行环境,eg:docker
- 基础镜像,eg:alpine:latest
3 修改gitlab仓库http下载链接(若非映射80端口需更改)
https://blog.csdn.net/kimqcn4/article/details/87089588
docker exec -it gitlab /bin/bash
vi /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: gitlab_http.test.com
port: 8080
https: false
time_zone: "Asia/Shanghai"
ssh_host: gitlab_ssh.test.com
ssh_port: 2222
gitlab-ctl restart
gitlab重启后该配置会失效,需要重新进入容器修改配置
4 设置公共runner的运行配置
runner-config.png runner-tag.png5 添加runner缓存配置(maven缓存,docker in docker缓存)
vim /home/gitlab-runner/config.toml
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "runner"
url = "http://1.???.??:1080/"
token = "JJtvxxxxxxxxxxxxjp"
executor = "docker"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "alpine:latest"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache","/.m2","/var/run/docker.sock:/var/run/docker.sock"]
shm_size = 0
网友评论