sonar-gitlab-plugin icon indicating copy to clipboard operation
sonar-gitlab-plugin copied to clipboard

Wrong branch used for the report

Open ivanrododendro opened this issue 5 years ago • 1 comments

Hi and thank you for the good job you do on this plugin.

We're are running :

  • Gitalab 11.10.4-ee
  • Sonarqube 7.7
  • gitlab-sonar-plugin-4.1.0-SNAPSHOT

and all looks ok.

In some cases we got a strange error on a long lived branch, named dev : the quality gates is passed
image (based on the URL in the logs) but the build is broken, because the plugin reports some blocking violations.

These violations are reported at line numbers which do no exist in the analyzed branch, but they do exists in a short-lived branch, the feature branch has never been analyzed.

image

This is our command line in .gitlab-ci.yml

    - mvn $MAVEN_CLI_OPTS clean verify sonar:sonar 
      -Dsonar.gitlab.project_id=$CI_PROJECT_ID
      -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA 
      -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
      -Dsonar.branch.name=$CI_COMMIT_REF_NAME
      -Dsonar.branch.target=$SONAR_BRANCH_TARGET

Gitlab debug traces show :

++ export SONAR_BRANCH_TARGET=
++ SONAR_BRANCH_TARGET=
...
++ export CI_COMMIT_REF_NAME=dev
++ CI_COMMIT_REF_NAME=dev

It looks like the plugin is taking the wrong branch to build its report or Sonarqube is giving the wrong reference to the plugin.

Thank you for your help

ivanrododendro avatar May 16 '19 13:05 ivanrododendro

+1

narwajea avatar May 16 '19 13:05 narwajea