Imediava's Blog

Just another site

Sonar: Hide snapshot from the TimeMachine

If you use Sonar ( as your code quality control tool maybe at some point you’ve wondered how you can delete a snapshots which no longer provide useful data.

You can run into this problem if you run a sonar measurement over a failed build or if you change the quality profile of your server for testing purposes and you wanna get rid of that confusing data later.

The problem is that those snapshots are not useful for you anymore yet there’s no way to hide them. This affects specially the TimeMachine section where the graph is altered by those useless snapshots.

As far as I know Sonar doesn’t provide a way to do this through it’s interface. The only alternative I’ve found it’s extracted from the following Jira issue:

To make use of this tip you need to have access to the database that stores Sonar data. Once you’re logged into the database server you can identify the ids of the snapshots you wanna hide with the following SQL query that list all the snapshots of a project:

select as snapshot_id,, p.kee,  s.created_at 
         from projects p, snapshots s 
         where s.project_id = and p.scope = 'PRJ' and p.qualifier='TRK' and name like "%MyProjectName%" 
         order by s.created_at desc

Now that we have the id of the snapshot we wanna hide we can make it invisible with the following update statement:

update snapshots 
         set status='U' 
         where root_snapshot_id='${snapshot_id}' or id ='${snapshot_id}'

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: