I have sonaqrube version 9.9.2 running and have it integrated with gitlab to generate reports. I want to run sonarqube and have it generate some static report file that I can set as a gitlab artifact. Either a PDF, HTML, or JSON, something like that. From what I can see, there are configuration values I can set, but they don’t seem to do anything. I am using a sonar-project.properties
. I’ve tried setting these values, but never see a report get generated in .scannerwork/ or anywhere that I can see.
# Quality Gate
sonar.qualitygate.wait=true
# Report generation
# HTML report
sonar.report.export.path=sonar-report.html
# JSON report
sonar.issuesReport.json.enable=true
sonar.issuesReport.json.location=sonar-report.json
sonarqube-check:
stage: analyze
tags:
- docker
# sonarqube needs the unit test coverage report
needs: ["unit-tests"]
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: 0 # Tells git to fetch all the branches of the project, required by the analysis task
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- mkdir -p $SONAR_REPORT_PATH
- mkdir -p $SONAR_REPORT_PATH/html
- sonar-scanner
- ls -la
- ls -la reports
- ls -la reports/sonar
- ls -la .scannerwork/
- cp .scannerwork/report-task.txt $SONAR_REPORT_PATH/report-task.txt
allow_failure: true
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
artifacts:
paths:
- ./reports/sonar/
- .scannerwork/
- sonar-report.html
- sonar-report.json