Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SonarQube - analyzing branches of the same project

Tags:

sonarqube

I know that there is no "new project" button on SonarQube UI. However, I have two branches of the same project that I want to do analysis on. The thing is that since the project names are the same, SonarQube will upload the analysis results of the two branches into the same project on SonarQube Server. How do I configure SonarQube so that one branch will upload analysis results to one project and the other branch will upload results to another project on SonarQube server?

like image 551
mrQWERTY Avatar asked Jul 16 '14 16:07

mrQWERTY


People also ask

What is SonarQube branch analysis?

Branch analysis is available as part of Developer Edition and more. Branch analysis allows you to: analyze long-lived branches. analyze short-lived branches. notify external systems when the status of a short-lived branch is impacted.

How do I create a branch as the main branch in SonarQube?

You must simply analyze the branch that you want to be your main without any sonar.branch.name parameter. This creates by default in SonarQube a branch named master.

How do I add a branch to SonarCloud?

On your project, go to Administration / Branches & Pull Requests. There, you will see in the top-right corner a text like this: "Long living branches pattern: (branch|release)-. * ". That means that when the name of the branch starts with branch- or release- , then it will be considered a long-living branch.


2 Answers

You might want to look at this part of the Sonar documentation, specifically at the sonar.branch parameter. It seems to be designed for what you want to do, and is working that way for us.

like image 104
Dennis S. Avatar answered Sep 22 '22 20:09

Dennis S.


As the sonar.branch parameter is deprecated and the Developer Edition costs money, one possible option it to use the already mentioned branch plugin for SonarQube Community Edition (LGPL).

Update: seems like the repo is gone, not sure why. Active fork can be found here.

like image 29
beat Avatar answered Sep 22 '22 20:09

beat