Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to re-analyze complete history of a project using Sonar?

I would like to load the entire project history since its inception into Sonar.

I would basically want to execute code like this:

0) checkout version 1 from Subversion
1) checkout next version from Subversion
2) if the commit date is from the same day as the previous one - goto 1
3) run mvn sonar:sonar, overriding the build time with the time of the commit
4) if not on last commit - goto 1

Is there a tool that does this already? Is there a way of convincing Sonar to use a different date than the current one?

like image 506
Roman Zenka Avatar asked Mar 28 '11 21:03

Roman Zenka


People also ask

How do you're analyze project on SonarQube?

You need to build your project in a specific way, and run the scanner afterwards. The build-wrapper is required to build your project. It will compile your project the normal way, but in the meantime creating a special output (. json) that will be used afterwards by the scanner.

Is it possible to maintain analysis history in SonarQube?

One of the most powerful features of SonarQube is that it shows you not just your project health today, but how it has changed over time. It does that by selectively keeping data from previous analyses (see Housekeeping). It doesn't keep all previous analyses - that would bloat the database.

How do I check SonarQube history?

2 Answers. Show activity on this post. If you use SonarQube up to version 5.6: Use the Sonar Timeline Plugin, which allows you to add a graph to your dashboard. If you use SonarQube version 6.5 or later (to be released in August 2017): Get feature rich history graphs out of the box (no plugin required)!


2 Answers

This is from the Mailing Lists:

Indeed, to import historical data you must use the "sonar.projectDate" property (Format is yyyy-MM-dd, for example 2010-12-25) [1] and launch a Sonar analysis on each tag/branch that you'd like to see in your project history.

http://sonarqube.15.x6.nabble.com/re-ordering-historical-data-td3191565.html

There is an additional Blogpost that explains this further.

like image 59
oers Avatar answered Oct 10 '22 21:10

oers


I was just searching for this exact same thing and found a handy bash script in GitHub:

https://gist.github.com/aslakknutsen/2422117

The script does a checkout of each tag (beginning from a specific tag given as a parameter), sets the tag date as sonar.projectDate and runs sonar analysis on it. Very handy. I think I might have to modify it a little bit since we don't have that much tags in the repo, maybe do a weekly analysis or something.

like image 20
Cvuorinen Avatar answered Oct 10 '22 20:10

Cvuorinen