Sonarqube Gradle Plugin : run analysis without version

I am using Sonarqube Gradle plugin 2.8. I want to do an analysis without setting the flag sonar.projectVersion. The documentation states that the default value is ${project.projectVersion}. How can I set a “null” version ?

Thanks

Hi,

Welcome to the community!

You can override the values automatically picked up from analysis by overriding them on the command line with -Dkey=value. But it’s really not possible to set a null project value. If you don’t provide one, SonarQube defaults it to… “Not provided” IIRC. I suppose you could use that for your overriding value.

 
HTH,
Ann

Hi,

Thanks for the answer !

If I set the version to “Not provided”, a new version with the name is created also.

image

Actually, I ask this because the version of my project changes for every commit (1.x.y.alpha.0, 1.x.y.alpha.1, etc) and I do not want to create a version in sonar for each commit (because my “New code period” is “Previous version”. I just want to create a version when I tag my application.

For the moment, I don’t understand how I can use the “New code period” in my case.

Hi,

Yes, that’s how it works. There will always be a “version” but if you always pass the same value then it’s essentially unversioned semantically.

Okay! So first, sonar.buildString was added to allow you to pass that in if it’s important to you to be able to cross-reference between a build and an analysis.

Also, it seems to me that you do have a “version”: 1.x.y.alpha. Presumably some part of that string changes when you deploy? If so, you could parse out the part that’s stable between releases and use that as your version string.

The idea behind a previous_version New Code Period is to track the changes since the last deployment, and what I described above would do it. Alternately, you can set a specific analysis as your New Code Period baseline (all the changes since this analysis), and passing in your sonar.buildString during analysis should help you identify which analysis to set as the baseline.

 
HTH,
Ann

Hi @ganncamp,

Thanks for the detailed answer. This helps. I did not know the sonar.buildString parameter !