问题
On this project: https://gitlab.com/tyvain/parcoursup/tree/master
I have a code quality stage:
code_quality:
stage: code_quality
image: docker:stable
variables:
DOCKER_DRIVER: overlay2
allow_failure: true
services:
- docker:stable-dind
script:
- 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: [gl-code-quality-report.json]
This stage always endup 'passed'. Logs: https://gitlab.com/tyvain/parcoursup/-/jobs/94665791
I doubt that my code is perfect, so there should be some code quality issues somewhere.
Where is the code quality report supposed to be output ?
What is this parameter: "paths: [gl-code-quality-report.json]" ?
回答1:
2 problems here:
- the report is only available for merge request in 'gitlab EE edition' (not free)
- the report can be downloaded as a json file here:
回答2:
GitLab parses and displays the results in merge requests. It works by comparing to previous code quality results, so the first time you merge the job into master
, you won't see anything. But, it should work on subsequent merge requests.
It's explained in a bit more detail here: Code Quality
回答3:
This is old, but adding this here, in case someone else stumbles on it. I found the same issue (success, but no output) and the result was that the test was timing out. There's a default 900 second timeout on the codeclimate engine. The images that codeclimate uses are well over 1.5gb of data, so they take forever to download on a slow connection. When they timeout they return exit code 0, but no reports.
Verified by doing this locally:
docker run \
--env CODECLIMATE_CODE=/path/to/my/code \
--env CONTAINER_TIMEOUT_SECONDS=9000 \
--volume /path/to/my/code:/code \
--volume /tmp/cc:/tmp/cc \
--volume /var/run/docker.sock:/var/run/docker.sock \
--env CODECLIMATE_DEBUG=1 "codeclimate/codeclimate:0.83.0" \
analyze -f json
Adding CONTAINER_TIMEOUT_SECONDS as an environment variable will allow you to surpass this, if timeout is your issue. I haven't gone further on using this in GitLab, as the documentation is lacking, and I only wanted checkstyle, not all the other stuff codequality comes with in GitLab, and the documentation wasn't clear on how to do that.
来源:https://stackoverflow.com/questions/52174028/gitlab-code-quality-where-is-the-report