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

4

14

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?

Mayenne answered 28/3, 2011 at 21:0 Comment(1)
I have the same question and I'm very interested about a script with the "sonar.projectDate". Did you write this script ? Thanks in advanceGenetics
M
13

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.

Martyrdom answered 29/3, 2011 at 7:1 Comment(0)
M
1

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.

Macadamia answered 15/3, 2013 at 14:32 Comment(0)
H
1

Python tool to load a snapshot for every month/week since a given date.

https://gist.github.com/Cassus/6229929

Horney answered 14/8, 2013 at 10:44 Comment(0)
W
1

Just find out the script from @adam-banko does not work for me anymore (since it is 8 years old).

Here is an updated Python3 script to upload historical snapshots of maven project: https://gist.github.com/hughluo/c51b14cfcd9afe3f89149f478c1a65d5

Usage

  1. Change the date range in the script to fit your needs.

  2. Put the script in the folder where your project root pom.xml located in and run

SONAR_HOST=<sonar.host.url> SONAR_LOGIN=<sonar.login> SONAR_PROJECT=<sonar.projectKey> python3 upload_snapshots_sonar.py
Windbroken answered 6/10, 2021 at 11:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.