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

Inline comment only generated in Master branch #210

Open jeoy opened 5 years ago

jeoy commented 5 years ago

I am using sonar-gitlab-plugin@4.0.0 and sonarQube@7.5,

My gitlab-ci.yml is:

sonar-scanner \
  -Dsonar.projectKey=$SONAR_KEY \
  -Dsonar.sources=. \
  -Dsonar.host.url=$SONAR_URL \
  -Dsonar.login=$SONAR_LOGIN
  -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA \
  -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME \
  -Dsonar.gitlab.project_id=$CI_PROJECT_ID

Commit in non-master branch

If this commit not on the Master branch, when quality gate is failed, SonarQube always generates global comment like below: commit in non-master branch

But always says "reported no issues" and `no inline comment`,

Commit in Master branch

However, commit in Master branch (with same changes), it generates global comment with issues and inline comments :

commit in Master branch


I expect it generates global comment with issues and inline comment on all branch.

Any help would be appreciated!

rafalur commented 5 years ago

I observe same issue, sonar-gitlab-plugin@4.0.0 and sonarQube@7.1,

gsumpster commented 5 years ago

I recently ran into this issue and found that it was because of a mismatch between the branch name being given to Sonarqube and the ref_name argument.

Try using these two arguments -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.branch.name=$CI_COMMIT_REF_NAME.

jeoy commented 5 years ago

I recently ran into this issue and found that it was because of a mismatch between the branch name being given to Sonarqube and the ref_name argument.

Try using these two arguments -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.branch.name=$CI_COMMIT_REF_NAME.

Hi , george, I can't use the arguments Dsonar.branch.name you mentioned, I am using Community Edition. Does sonar branch relate gitlab branch ?

rafalur commented 5 years ago

I recently ran into this issue and found that it was because of a mismatch between the branch name being given to Sonarqube and the ref_name argument. Try using these two arguments -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.branch.name=$CI_COMMIT_REF_NAME.

Hi , george, I can't use the arguments Dsonar.branch.name you mentioned, I am using Community Edition. Does sonar branch relate gitlab branch ?

It looks that it's limitation of community edition. Analysis is run only on master branch. Too bad....

gsumpster commented 5 years ago

Yup, unfortunately you won't be able to analyze multiple branches on the community edition and I believe the Gitlab Issues come from the branches issues even if the quality gate works... I don't think anything can be done about this w/o upgrading.

tangngocphu commented 5 years ago

@jeoy . Why don't you try open source branch plugin: https://github.com/msanez/sonar-branch-community I installed it, and it work for me with other branch than master

hd-deman commented 5 years ago

@jeoy . Why don't you try open source branch plugin: https://github.com/msanez/sonar-branch-community I installed it, and it work for me with other branch than master

This plugin is deprecated !

dominikmontada commented 5 years ago

@jeoy . Why don't you try open source branch plugin: https://github.com/msanez/sonar-branch-community I installed it, and it work for me with other branch than master

This plugin is deprecated !

In the docs it links to the current version of the plugin. It seems to be maintained and supposedly works with version 7.4+. I can't test it out myself, but would this work?

xiaomaodan110 commented 3 years ago

I has installed the sonar-branch-community plugin. But I still has the same issue as you. Have you solved the problem? If you can give me some advice , I will be grateful.

xiaomaodan110 commented 3 years ago

@jeoy . Why don't you try open source branch plugin: https://github.com/msanez/sonar-branch-community I installed it, and it work for me with other branch than master

Hi, Do your Gitlab VERSION is Commuity Edition? I have installed the same plugin, But it doesn't work .Could you please help me?

xiaomaodan110 commented 3 years ago

Oh! I got some tips. If I do not analyze my primary branch(master) by sonarqube. It will occur no issue. But if I do it , other branchs will return master branch's report,like this. and it still has no inline comment.

So I think it should be the community edition branch function leads to it.

image