sonar.projectVersion not working from sonar-scanner

I am using SonarQube Developer Edition Version 8.1 (build 31237) with SonarQube Scanner 4.2.0.1873 (which seems to be the latest as of time of writing). I am trying to pass a version number for a new scan.

If I add sonar.projectVersion=1.2.3 into the sonar-project.properties file, this works fine. The new analysis is shown as version 1.2.3.

However, if I pass it on the command line (e.g. using sonar-scanner -Dsonar.projectVersion=1.2.3), it makes no difference to not passing it. I’ve googled myself silly, but it seems that’s the way it should work and there’s no typo afaict, but it just does not do anything.

I am trying that for a C++ as well as for a Python-only project, with no difference.

Is there something I am missing?

How about -Dsonar.projectVersion=1.2.3 instead of sonar-scanner -Dsonar.projectVersion=1.2.3?

If you mean without a space between the dash and the D, then that’s exactly what I did (it just is displayed strangely here). But while re-testing it, I found the issue - I had a wrapper for deployment purposes which passed on the arguments incorrectly (stupid bug).

So this was an error on my side, nothing to do with sonar-scanner. Sorry for wasting everyone’s time :frowning: