Issue: SonarQube Report Not Generated in GitLab CI
I’m using GitLab CI for code quality checks with SonarQube. My SonarQube instance is running on an EC2 virtual machine, and I’m using the SonarQube CLI to push the code quality reports to SonarQube. However, I’m encountering an issue where the report is not being generated.
GitLab CI Configuration
.gitlab-ci.yml
sonarqube-check:
stage: analysis
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
GIT_DEPTH: "0"
SONAR_URL: "http://143.127.12.15:9000"
SONAR_TOKEN: $SONAR_TOKEN
cache:
key: php_vendor
paths:
- .sonar/cache
script:
- sonar-scanner
artifacts:
paths:
- report.json
allow_failure: true
sonarqube_report_download:
stage: download
image:
name: alpine:latest
needs: ["sonarqube-check"]
script:
- apk update
- apk add curl
- mkdir -p Sonar_Report
- curl -u $SONAR_TOKEN "$SONAR_URL/api/issues/search?projectKeys=phpprojecttest" -o Sonar_Report/report.json
artifacts:
paths:
- Sonar_Report/report.json
This is sonar-properties
sonar.projectKey=phpprojecttest
sonar.projectName=phptest
sonar.sourceEncoding=UTF-8
sonar.host.url=http://143.127.12.75:9000
sonar.login=sqp_fc4da4b3b4a22b221045463956
sonar.sources=.
sonar.exclusions=**/vendor/**
sonar.tests=tests
sonar.test.inclusions=**/*.test.php
sonar.php.coverage.reportPaths=coverage.xml
Here I need to Generate the Sonarqube Report.json or xml file which i need to upload in the defectdojo.