Evaluating Sonarqube (Version 5.4), we want to migrate our current workflow
using another Audit tool, which works like that :
The current version that runs in production is our reference version.
A new development version is checked out from GIT, a diff process calculates the new and modified files vs.
the reference version and starts the audit for these files.
There's also a slightly different handling of legacy code (components that already existed in 2012) and
new components (after 2012).
The build breaks if :
Blocker issues in changed files (those files already existing in 2012) from legacy components
Blocker or critical issues in new files (files created after 2012) from legacy and new components
How to implement that in Sonarqube ?
Tried two things already :
1.) Set property sonar.timemachine.period1
to the production/reference version in Ant script before starting Sonar task => didn't work,
it's always 'since previous version'
2.) Define two different projects in Sonarqube, one for the production versions and one for the new dev versions. Then programmatically use the feature known from Sonarqube Web UI More / Compare Projects and get the diff for Blocker and Critcal issues.
Problem : f.e. i'll get no diff for Critical issues if i have fixed 200 Critical issues that already existed in my production
reference, but introduced 200 new issues in the development version.
The Compare Projects feature has no metric for new or old issues, it's just counting issues for the compared projects.
The
sonar.timemachine.period1
property has to be set via REST call (documentation here), before calling the Sonar task - if defined with Ant property task, it isn't transferred to Sonarqube Server. Works like that, created a macrodef for reuse :Somehow i expected to see the sonar.timemachine.period1 in
Sonarqube Server Web UI / Administration /General Settings / Differential Views
after the REST call but that's not the case.
Note => Instead of using
username:password
forBasicAuth
, simply create a usertoken athttp://sonarhost/account/security
and use usertoken: instead - means usertoken as userid with separator ':' and a blank password.