How to make all branches in gitlab project to reflect as same project in sonarqube presently master and its branches are reflecting as different projects in sonar

sonarqube

(Rajaneesh K) #1

I am using SonarQube 6.1v,SonarScanner 3.1.0
and in sonarqube analysis i mentioned
sonar.projectKey=$JOB_NAME
sonar.projectName=$JOB_NAME
sonar.projectVersion=1.0
soanr.branch=dev
sonar.sources=src
for branch specifier i gave master */master for branch */devbranch
I am getting master as a project and branch as different project in sonarqube how to resolve it I need all branches on a single project in SONARQUBE???


(Gilbert Rebhan) #2

Hi,
branch analysis (several branches in one Sonarqube project) is only available in Developer Edition or higher. The use of sonar.branch property is deprecated in version 6.7, if used it will create a new Sonarqube project per branch, it always worked that way.
Details:
Branch Analysis
Analysis parameters
Finally you should consider updating your Sonarqube and SonarScanner versions.
There’s also a branch plugin for SonarQube Community Edition never tried that.
Regards,
Gilbert


(Rajaneesh K) #3

thanks for the reply But I tried using sonarqube version 7.1 but unable to get the output can you explain me how to make this happen (several branches in one Sonarqube project) please mention the version to be used (Sonarqube and SonarScanner).


(Gilbert Rebhan) #4

Hi,
in general you should use at least the current LTS version (6.7.6 right now) or even the newest Sonarqube version (7.6 right now) , to benefit from increased performance, new features and bugfixes.
Also the SonarScanner has already version 3.3.
Once again, to be able to use the branching feature from Sonarsource you will need the Developer Edition or higher (Enterprise …). Alternatively with the Community Edition, you might be able to use
the branch plugin for SonarQube Community Edition - note the compatibility given on the github page. The github readme has “There are currently no usage differences to Branch Plugin.” which means after installing that plugin - don’t know if it really works, as i never used it, we use SQ 7.6 Enterprise - using the property sonar.branch.name should create a new branch .
A look into the sonarqube documentation might be helpful too:
Branch Analysis look for sonar.branch.name
Analysis parameters look for sonar.branch
Regards,
Gilbert


(Rajaneesh K) #5

Hi Gilbert,

Thanks for the followup…

May I know how in the developer edition can we make sure that the SonarQube analysis is done separately for master as well as its branches in a single project in Sonarqube…

finally I have see
separate analysis for master and separate analysis for branch in same project in SonarQube.

Please provide the procedure and analysis parameters defining.


(Gilbert Rebhan) #6

Hi,
did you read the documentation for Branch Analysis carefully ?!
You have to use the relevant properties
sonar.branch.name and sonar.branch.target
Regards,
Gilbert


(Rajaneesh K) #7

Hi,

I have gone through the documentation but sonarqube analysis is done on master and it’s only visible in the dashboard I need even branches to be visible…how to achieve it in community edition???


(Gilbert Rebhan) #8

Hi,
i can’t help you with the branch plugin for SonarQube Community Edition, i never used it.
Their readme on the github site has:
“Usage
Project must exists before scanning branches other than master. There are currently no usage differences to Branch Plugin.”
Pluginversion 2.0.0 is said to be compatible with Sonarqube 7.1
So theoretical it should work when using the properties sonar.branch.name and sonar.branch.target
If it doesn’t work as expected, you should contact the maintainer or create an issue on the github page.
Regards,
Gilbert