docker中gitlab-runner配置
Posted river2005
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker中gitlab-runner配置相关的知识,希望对你有一定的参考价值。
1、启动gitlab-runner
docker run -d --name gitlab-runner --restart always -v /opt/data/gitlab-runner/config:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner
2、注册runner
docker exec -it gitlab-runner gitlab-ci-multi-runner register -n
--url http://gitlab.8dat.com/ci
--registration-token ip-Adefsfsfasdfdsfjkljd --tag-list=dev,uat,prod --description "project_build_runner" --docker-privileged=false --docker-pull-policy="if-not-present" --docker-image "mvn-jdk:latest" --docker-volumes /var/run/docker.sock:/var/run/docker.sock --docker-volumes /opt/data/gitlab-runner/.m2:/root/.m2 --executor docker
注: url 和token来自 gitlab 的 Settings--> CI/CD --> Runners
进入gitlab-runner容器生成的配置文件 cat /etc/gitlab-runner/config.toml
,如下所示:
[[runners]] name = "dev_build_runner" url = "http://gitlab.XXX.top/" token = "9103bafa16b1f63232323434345" executor = "docker" [runners.docker] tls_verify = false image = "mvn-jdk:latest" privileged = false disable_cache = false volumes = ["/cache","/opt/data/gitlab-runner/.m2:/root/.m2"] pull_policy = "if-not-present" shm_size = 0 [runners.cache]
3、 project中.gitlab-ci.yml的内容如下:
image: mvn-jdk:latest variables: MAVEN_OPTS: "-Dmaven.repo.local=/root/.m2/repository" stages: - build build:config: stage: build script: - mvn clean package -DskipTests
以上是关于docker中gitlab-runner配置的主要内容,如果未能解决你的问题,请参考以下文章
gitlab-runner config for docker runner