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
codequality: image: docker:latest variables: DOCKER_DRIVER: overlay services: - docker:dind script: - docker pull codeclimate/codeclimate - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/') - docker run --env SOURCE_CODE="$PWD" \ --volume "$PWD":/code \ --volume /var/run/docker.sock:/var/run/docker.sock \ "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code artifacts: paths: [codeclimate.json]
The above example will create a
codequality job in your CI/CD pipeline which
will scan your source code for code quality issues. The report will be saved
as an artifact that you can later download and analyze.
codequalityand the artifact path must be
codeclimate.json. Learn more on code quality diffs in merge requests.