How to achive Branch analysis different for master and its branches

I need to figure it out differently…How to do it ? I have installed the branch plugin for SonarQube 7.1 version and its not helping me… only master is visible in SonarQube

My planned organization for the Branch Plugin is as follows:

  1. The “Main” branch is my “Master” branch
  2. The long-lived branches are any “DevBranch” branches
  3. The short-lived branches are any “feature,” “hotfix,” “bugfix,” or malformed-named branches

I’m trying to figure out how to get this working (what steps I need to do and when). Assume that I’ve got a clean SonarQube server and the sonar scanner/runner.

My questions are:

  1. How do I define the main branch so that analysis are made separately for master and its corresponding branches?

  2. Do I need to change the [sonar.branch.name] for master and its branches please mention how to do?

  3. We are following the maven <groupId>:<artifactId> pattern with no additional information

  4. Our sonar.projectName is provided through sonar analysis section in post build actionbs in Jenkins.

Presently I am getting both Master and its branches in same analysis I am unable to differentiate between the master sanalysis and branch analysis in sonarqube…

sonar.projectKey=$JOB_NAME
sonar.projectName=$JOB_NAME
sonar.projectVersion=1.0 for master and 2.0 for dev
sonar.projectKey=$JOB_NAME
soanr.branch.name=“master”/for devbranch I change here /“devBranch”
sonar.sources=/var/lib/jenkins/workspace/
sonar.java.binaries=**/target/classes

Hi,
Branch analysis has had a lot of improvements throughout the 7.x series.
Could you upgrade to SQ 7.6?

Then, all you have to do is:

  • Define, in the UI, what pattern to use to classify a branch as a short or long living.
  • First analyze master, by not providing any parameters related to branches.
  • Then, when analyzing a branch, provide the following parameters to the SonarQube Scanner: -Dsonar.branch.name=xxx and -Dsonar.branch.target=yyy.
1 Like

Hi Meneses,

Thanks for the followup…

Can you please share a screenshot of differential analysis done on master and branch on a single sonarqube project.

Here is an example:
https://next.sonarqube.com/sonarqube/dashboard?id=org.sonarsource.java%3Ajava

This project has several branches and pull requests. You can switch branches on the drop down menu on top, next to the project’s name.

Hi,

Is the drop-down available for community edition of sonarqube???If yes please tell how to configure in Jenkins to achieve it…If no which edition do I need…

Support for branches is not available in the community edition.
It’s part of the developer edition. You can find more information here: https://www.sonarsource.com/plans-and-pricing/

Hi,

I came across a plug-in called branch plugin will that help me to achieve it in community edition.

How can we compare different branches of a project and show it on a single dashboard in soanarqube.

Please provide a screenshot if already implemented try share the procedure…

That plugin is not developed by SonarSource and I’m not able to help with it.
Most likely it will only support a small part of the branch feature as offered by the developer edition.

Is there any way to showcase different branches analysis of same project on single dashboard…i.e I want to know which branch is efficient…

Can we compare different branches of a project and show it on a single dashboard in SonarCloud for free???

Hi,

This link is not helping me to find out the analysis done on different branches of a project on sonarqube.

I just see the MASTER and PULL REQUESTS.

Can you please share a link which can show MASTER and BRANCHES(in DROP-DOWN).

Here are two screenshots: one of the drop down, other from the page to manage branches.
If you would like to know more about what is offered by the developer edition and get a trial license to try it out, you can contact us through the form here.

Hi,

Thanks for the follow up…

Can I get a trail version of the developer edition like for few hours so that I can come to a conclusion and take a Decision.

Hi,
Sure, you can request a trial here: https://www.sonarsource.com/plans-and-pricing/developer

why we need to analyze the master first ?
is there any way we can override that settings ?

Hi,

Can main branch be defined other than master? How (on an onPrem developer edition)?

Tnx

Hi,
You can rename the main branch.
Go to the Administration menu, select Branches & Pull Requests and you’ll have that option in the Actions for the current main branch.

Noob question relevant (I hope) to this thread: The SonarQube metrics icons are displayed only for the master branch on BitBucket. I would like them to appear for all long-living branches.

I have “Enable plug-in for branches matching regex only” set to ((?!feature/).)*

Can someone let me know how to accomplish this? Thanks.