首页 > 解决方案 > Gitlab CI 运行代码质量不生成 .json 文件

问题描述

我按照官方指南部署了一个管道来分析我的代码质量。尽管管道通过并且作业成功,但 json 文件不是由 docker 生成的。这些通知显示:

警告:有新版本 (v0.83.0) 可用。升级说明位于:https ://github.com/codeclimate/codeclimate#packages 上传工件...警告:gl-code-quality-report.json:没有匹配的文件错误:没有文件上传
作业成功

这是我的/etc/gitlab-runner/config.toml文件:

    concurrent = 1
    check_interval = 0

    [session_server]
      session_timeout = 1800

    [[runners]]
      name = "code_quality"
      url = "http://192.168.0.2/"
      token = "pyKK8v9C6Bnay8yMmfph"
      executor = "docker"
      [runners.docker]
        tls_verify = false
        image = "docker:stable"
        privileged = true
        cache_dir = "cache"
        disable_entrypoint_overwrite = false
        oom_kill_disable = false
        disable_cache = false
        volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock"]
        shm_size = 0
      [runners.cache]
        [runners.cache.s3]
        [runners.cache.gcs]

我的 Gitlab 版本是 11.7

这是我的.gitlab-ci.yml文件:

 code_quality:
      tags: 
        - quality
      image: docker:latest
      variables:
        DOCKER_DRIVER: overlay2
      before_script:
      - ip -4 a
      allow_failure: true
      services:
        - name: docker:stable-dind
          command: ["--insecure-registry=192.168.0.1:5000"]
      script:
        - ip -4 a
        - docker pull 192.168.0.1:5000/codeclimate:0.72.0
        - docker tag 192.168.0.1:5000/codeclimate:0.72.0 codeclimate/codeclimate:0.72.0
        - docker pull 192.168.0.1:5000/codeclimate-coffeelint:latest
        - docker tag 192.168.0.1:5000/codeclimate-coffeelint:latest codeclimate/codeclimate-coffeelint:latest
        - docker pull 192.168.0.1:5000/codeclimate-csslint:latest
        - docker tag 192.168.0.1:5000/codeclimate-csslint:latest codeclimate/codeclimate-csslint:latest
        - docker pull 192.168.0.1:5000/codeclimate-eslint:latest
        - docker tag 192.168.0.1:5000/codeclimate-eslint:latest codeclimate/codeclimate-eslint:latest
        - docker pull 192.168.0.1:5000/codeclimate-rubocop:latest
        - docker tag 192.168.0.1:5000/codeclimate-rubocop:latest codeclimate/codeclimate-rubocop:latest
        - docker pull 192.168.0.1:5000/codeclimate-fixme:latest
        - docker tag 192.168.0.1:5000/codeclimate-fixme:latest codeclimate/codeclimate-fixme:latest
        - docker pull 192.168.0.1:5000/codeclimate-structure:latest
        - docker tag 192.168.0.1:5000/codeclimate-structure:latest codeclimate/codeclimate-structure:latest
        - docker pull 192.168.0.1:5000/codeclimate-duplication:latest
        - docker tag 192.168.0.1:5000/codeclimate-duplication:latest codeclimate/codeclimate-duplication:latest
        - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
        - docker images
        - docker run
            --env SOURCE_CODE="$PWD"
            --env CODECLIMATE_VERSION=0.72.0
            --env TIMEOUT_SECONDS=900
            --volume "$PWD":/code
            --volume /var/run/docker.sock:/var/run/docker.sock
            192.168.0.1:5000/codequality:latest /code
      artifacts:
        reports:
          codequality: gl-code-quality-report.json

由于我想提高拉图像的速度,所以我在 localhost 中部署了一个 docker 注册表。

你能给我一些建议吗?

谢谢你们!

标签: dockergitlabgitlab-cidocker-in-docker

解决方案


无论如何,几个月后,如果您使用的是 Gitlab CE,这将无法正常工作,这只是 EE 的功能。


推荐阅读