码迷,mamicode.com
首页 > 其他好文 > 详细

docker中gitlab-runner配置

时间:2018-08-24 00:31:58      阅读:974      评论:0      收藏:0      [点我收藏+]

标签:wrap   variable   .com   cache   can   sfasdf   rod   space   neu   

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配置

标签:wrap   variable   .com   cache   can   sfasdf   rod   space   neu   

原文地址:https://www.cnblogs.com/river2005/p/9527030.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!