Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running maven sonar:sonar on multiple branches of the same source project

We currently have multiple feature releases in perforce. Each of these branches has POM files that contain a version tag and name tag that is tied to that branch.

When we run sonar:sonar each branch scan overwrites another branch scan and you only see one at a time in the sonar gui.

Can a sonar project be tied to maven GroupId>ArtifactId>Version or even instead of just being Tied to the GroupId.

FYI, GroupId and ArtifactId do not change when we branch the POM.

like image 603
user3272389 Avatar asked Feb 04 '14 19:02

user3272389


People also ask

How do I add a branch to SonarQube?

You can set a branch to Keep when inactive at the project level from from the Branches tab at Project Settings > Branches and Pull Requests.

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.

How does Maven project integrate with sonar?

Before we could integrate our Maven project to SonarQube, We will need to integrate SonarQube Scanner in our POM. XML. SonarQube Scanner is recommended since it is the default launcher to analyze a project with SonarQube. // You can also replace the IP with your own IP or just say localhost instead.

What does Mvn sonar sonar will do?

What happens when you run mvn sonar:sonar is that an analysis report is generated and submitted to the server for asynchronous processing. Once the report is successfully submitted to the server, the local process ends.


1 Answers

I found your question while searching for a similar topic, and I noticed you had not received an answer. If you pass the -Dsonar.branch, each branch will be treated as a different project. As documented here:

http://sonarqube.15.x6.nabble.com/Sonar-Analysis-for-Feature-Branches-td5004642.html#a5004647

Hope this helps.

like image 174
user3704176 Avatar answered Oct 16 '22 06:10

user3704176