in gitlab, I have a pipeline which generate a code climate report, supposed to be displayed in the gitlab widget.
The report is successfully generated (I added cat code-quality.json
but I have the message «Failed to load codeclimate report».
When I check the source code of the gitlab page, I see a string which seems to contains the code responsible of the problem:
window.gl.mrWidgetData = { … ,"codeclimate":{"head_path":"/needhelp/needhelp-web/-/jobs/123456789/artifacts/download?file_type=codequality\u0026proxy=true","base_path":"/needhelp/needhelp-web/-/jobs/987654321/artifacts/download?file_type=codequality\u0026proxy=true"},"…
When I copy/paste the path in my url bar without the \u0026proxy=true
, the file is successfully downloaded.
Here the .gitlab-ci.yml
configuration which generate the file.
static analysis:
stage: test
interruptible: true
image:
name: $CI_QA_IMAGE
entrypoint: [""]
script:
- composer install --prefer-dist --no-progress --classmap-authoritative --quiet
- php bin/console --env=test cache:warmup
- |
./vendor/bin/phpstan analyze -c phpstan.neon --no-progress --memory-limit 1G --error-format=gitlab > code-quality.json && phpstan_error=0 || phpstan_error=1
if [[ -n $phpstan_error ]]; then
echo -e '\e[103;1mphpstan detected errors.\e[0m'
ls -lh code-quality.json
cat code-quality.json
./vendor/bin/phpstan analyze -c phpstan.ci.neon --no-progress --memory-limit 1G
else
echo -e '\e[92;1mphpstan detected no error with levelmax configuration.\e[0m'
fi
- bin/console lint:twig --env=test
- bin/console lint:container --env=test
- bin/console lint:xliff translations/ --env=test
artifacts:
when: always
reports:
codequality: ./code-quality.json
Do you know what is wrong with this code ? Or if it's ok, where should I look to fix this ?
One possible reason is gitlab failed to parse
code-quality.json
You can use some tool to validate the json format, for example: http://json.parser.online.fr/