Gitlab DID缓存无法正常工作

时间:2018-02-13 09:18:23

标签: docker gitlab gitlab-ci gitlab-ci-runner

我在我的本地服务器上安装了Gitlab的Omnibus,在另一台服务器上安装了执行CI任务的gitlab-runner。

在我的管道中,我有一个Job,它使用Docker In Docker和codeclimate检查代码质量。

问题是它非常慢(20分钟),因为每次下载并提取codeclimate的docker镜像。

docker pull codeclimate/codeclimate
Using default tag: latest
latest: Pulling from codeclimate/codeclimate 
2f3f3e5e133b: Pulling fs layer
2654c654a6e7: Pulling fs layer
412e64056adf: Pulling fs layer
a3ed95caeb02: Pulling fs layer
b79986a12326: Pulling fs layer
1bbb14422caf: Pulling fs layer
46bd7e5026ba: Pulling fs layer
7df61bb88827: Pulling fs layer
0381f4ee19b5: Pulling fs layer
7df87a0871f8: Pulling fs layer
4d99acb499d7: Pulling fs layer
ee6a20c6ea98: Pulling fs layer
cb945e8bccc7: Pulling fs layer
a789fd50eff6: Pulling fs layer
1bbb14422caf: Waiting
46bd7e5026ba: Waiting
7df61bb88827: Waiting
a3ed95caeb02: Waiting
b79986a12326: Waiting
7df87a0871f8: Waiting
4d99acb499d7: Waiting
cb945e8bccc7: Waiting
a789fd50eff6: Waiting
ee6a20c6ea98: Waiting
412e64056adf: Download complete

我尝试配置gitlab-ci缓存但没有任何改变。

cache:
    paths:
      - build
      - .gradle
    untracked: true

stage: reports
  image: docker:latest
  before_script: []
  variables:
    DOCKER_DRIVER: overlay2
  services:
    - docker:dind
  script: 
    - docker info
    - docker pull codeclimate/codeclimate
    - mkdir -pv build/reports/codequality
    - cp .codeclimate.yml src
    - docker run --env CODECLIMATE_DEBUG=1 --env CODECLIMATE_CODE="$PWD/src" --volume "$PWD/src":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate validate-config
    - docker run --env CODECLIMATE_DEBUG=1 --env CODECLIMATE_CODE="$PWD/src" --volume "$PWD/src":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze -f html > build/reports/codequality/codequality.html
    - docker run --env CODECLIMATE_DEBUG=1 --env CODECLIMATE_CODE="$PWD/src" --volume "$PWD/src":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze -f json > build/reports/codequality/raw_codequality.json
    - cat build/reports/codequality/raw_codequality.json
    - cat build/reports/codequality/raw_codequality.json | docker run -i stedolan/jq -c 'map({check_name,fingerprint,location})' > build/reports/codequality/codequality.json
    - rm src/.codeclimate.yml

这是我的config.toml

[[runners]]
  name = "DockerBuilder"
  url = "http://gitlab.mycompany.com"
  token = "mytoken"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "docker:latest"
    privileged = true
    disable_cache = false
    volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock", "/etc/default/docker:/etc/default/docker", "/etc/docker/daemon.json:/etc/docker/daemon.json"]
    extra_hosts = ["localhost:172.X.X.X"]
    shm_size = 0
  [runners.cache]

我已遵循本指南:Analyze project code quality with Code Climate CLI

0 个答案:

没有答案