How do you import the code quality report into Gitlab?

I struggle to get the report shown in Gitlab and I’m not sure what exactly I’ll have to change. So, how can I get the metrics shown here?

Our Gitlab license is “Premium” and as long as we evaluate Sonarqube we use the community edition. 10.x.

Gitlab CI Config:

Sonarqube:
  stage: sonarqube-check
  image:
    name: sonarsource/sonar-scanner-cli:5.0
    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
    SONAR_HOST_URL: "${SONAR_HOST_URL}"
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  script:
    - sonar-scanner
  allow_failure: true
  rules:
    - if: $CI_COMMIT_BRANCH
    - if: '$CI_COMMIT_REF_NAME == "master"'
    - if: '$CI_COMMIT_REF_NAME == "main"'
    - if: '$CI_COMMIT_REF_NAME == "develop"'
  artifacts:
    reports:
      codequality: gl-code-quality-report.json

Sonar Scanner Config:

# SonarQube configuration file
# https://docs.sonarsource.com/sonarqube/9.9/analyzing-source-code/analysis-parameters/

sonar.projectKey=clipmyhorsetv_cockpit_cb25df34-7525-4524-ab99-eac6e9515bb5
sonar.qualitygate.wait=false
sonar.qualitygate.timeout=300

sonar.sources=src,public,config
sonar.tests=tests

sonar.php.coverage.reportPaths=coverage.xml
sonar.php.tests.reportPath=phpunit.report.xml

Hey there.

The Code Quality tab in GitLab is a Gitlab feature, and actually has nothing to do with SonarQube.

In theory, we could develop a feature to generate a report that can be read by GitLab, but it’s not on our to-do list for now.