gabrie-allaigre / sonar-gitlab-plugin

Add to each commit GitLab in a global commentary on the new anomalies added by this commit and add comment lines of modified files
GNU Lesser General Public License v3.0
713 stars 207 forks source link

Wrong branch used for the report #242

Open ivanrododendro opened 5 years ago

ivanrododendro commented 5 years ago

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

We're are running :

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

narwajea commented 5 years ago

+1