Add comment automatically on gitlab after sonarqube has scanned

I expected to sonarqube scanner our code on gitlab, and then I will see my code has comment if changed code has issue.

This plugin has more detail description, but it only support SonarQube < 7.7, because preview mode is removed.

I would be thankful if you would provide us with detail videos or documents.

This feature is important to our team.

gitlab screen

I use the following software.

Sonar software:

SonarQube 8.1 developer editon (build on docker)
https://hub.docker.com/_/sonarqube/

SonarScanner ( build on CI/CD):

Gitlab

.gitlab-ci.yml


image:
  name: sonarsource/sonar-scanner-cli:latest
  entrypoint: [""]
variables:
  SONAR_TOKEN: XXXXX
  SONAR_HOST_URL: http://XX.XX.XX.XX:9000
  GIT_DEPTH: 0
  SONAR_ENCODING: UTF-8
  SONAR_GITLAB_USER_TOKEN: XXXXXXXXX
sonarqube-check:
  stage: test
  script:
    - sonar-scanner -Dsonar.qualitygate.wait=true -Dsonar.gitlab.only_issue_from_commit_line=true -Dsonar.gitlab.only_issue_from_commit_file=true
  allow_failure: true

sonar-project.properties

sonar.projectKey=org.example:spring-boot
sonar.java.binaries=.
sonar.sourceEncoding=UTF-8

Hi @DanielDu,

Welcome to our community !

If I understand correctly, you’d like to see the issues directly in your diff file in the MR in GitLab, in the code.
SonarQube (developer starting 8.1) decorates MR by adding a general comment in the MR and the quality results of the MR like this :

We don’t support issues directly in the file in the MR in GitLab yet but this is in our roadmap for this year.
Stay tuned !

Cheers,

1 Like