debian-mirror-gitlab/doc/ci/examples/code_climate.md

35 lines
1.4 KiB
Markdown
Raw Normal View History

2017-09-10 17:25:29 +05:30
# Analyze project code quality with Code Climate CLI
This example shows how to run [Code Climate CLI][cli] on your code by using
GitLab CI and Docker.
First, you need GitLab Runner with [docker-in-docker executor][dind].
2018-03-17 18:26:18 +05:30
Once you set up the Runner, add a new job to `.gitlab-ci.yml`, called `codequality`:
2017-09-10 17:25:29 +05:30
```yaml
2018-03-17 18:26:18 +05:30
codequality:
2017-09-10 17:25:29 +05:30
image: docker:latest
variables:
DOCKER_DRIVER: overlay
services:
- docker:dind
script:
- docker pull codeclimate/codeclimate
2018-03-17 18:26:18 +05:30
- 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:0.69.0 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:0.69.0 analyze -f json > codeclimate.json || true
2017-09-10 17:25:29 +05:30
artifacts:
paths: [codeclimate.json]
```
2018-03-17 18:26:18 +05:30
This will create a `codequality` job in your CI pipeline and will allow you to
2017-09-10 17:25:29 +05:30
download and analyze the report artifact in JSON format.
2018-03-17 18:26:18 +05:30
For [GitLab Starter][ee] users, this information can be automatically
2017-09-10 17:25:29 +05:30
extracted and shown right in the merge request widget. [Learn more on code quality
diffs in merge requests](https://docs.gitlab.com/ee/user/project/merge_requests/code_quality_diff.html).
[cli]: https://github.com/codeclimate/codeclimate
[dind]: ../docker/using_docker_build.md#use-docker-in-docker-executor
2018-03-17 18:26:18 +05:30
[ee]: https://about.gitlab.com/products/