gitlab-org--gitlab-foss/doc/ci/examples/code_climate.md
Shinya Maeda 16719ce107 fix doc
2017-08-31 15:57:31 +09:00

1.4 KiB

Analyze project code quality with Code Climate CLI

This example shows how to run Code Climate CLI on your code by using GitLab CI and Docker.

First, you need GitLab Runner with docker-in-docker executor.

Once you set up the Runner, add a new job to .gitlab-ci.yml, called codequality:

codequality:
  image: docker:latest
  variables:
    DOCKER_DRIVER: overlay
  services:
    - docker:dind
  script:
    - docker pull codeclimate/codeclimate
    - docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate init
    - docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze -f json > codeclimate.json
  artifacts:
    paths: [codeclimate.json]

This will create a codequality job in your CI pipeline and will allow you to download and analyze the report artifact in JSON format.

For GitLab Enterprise Edition Starter users, this information can be automatically extracted and shown right in the merge request widget. Learn more on code quality diffs in merge requests.