Reg. sonar.projectVersion in SonarQube and Revision number in SVN

I am using SonarQube to analyze source code, and only code with a ‘Passed’ status should be released. This means I need to ensure that the checked-in source is analyzed before being requested for release. Is there any way to retrieve the checked-out version from SVN and display it on the SonarQube dashboard after analysis? Shall I provide the SVN committed version number in ‘sonar.projectVersion’?

Hey there.

I suppose you could add the reference to sonar.projectVersion, although changing the version on every analysis can mess up housekeeping and the new code period (if you use a new code period of “previous version”, you should stop doing that if you choose this approach).

You might also consider just stopping the problem at the source, and breaking the build in your CI sonar.qualitygate.wait to prevent any further deployment if the QG is failing (if your CI/CD is at that level. With SVN, I’m not sure it will be :laughing:)

Thank you for the reply. I am setting sonar.projectVersion in the format _<svn_revision> and using a new code period of “previous version”. How will it affect my analysis?

It means your new code period will get reset on every analysis.

I am building and releasing our project in Jenkins. Before every build and release process, I need to analyze our project through SonarQube. The build and release process should start only if the quality of the project gets passed. For that, I am using sonar.projectVersion in the format _<svn_revision> and using a new code period of “previous version”. This method is Ok or I should chnage any configuration? For the above purpose, our new code period should get reset on every analysis, right?

Hey there.

I do intend to come back to this thread, but I didn’t have the chance this week.

In the situation you’re describing – yes, the New Code Period would get reset on every analysis. That is not typically desirable because then the New Code Period gets wiped away and replaced every time you perform analysis.

Are you continuously analyzing your code (with each revision), or only before certain scheduled releases?