`sonar.projectVersion` from git tag

Currently they is no documentation whether sonarcloud can automatically update sonar.projectVersion from the git tag without having to call sonar-scanner with --define sonar.projectVersion=...

This can easily be achieved from the github webhook if no additional analysis is done. Then all the subsequent PRs can use the git describe --tags to find the closest git tag and use that as default for sonar.projectVersion.

Hey there.

This sounds like something that would be technically possible, but I’m not sure it would be desirable in all circumstances. I’d also be wary of corner cases (what happens if there’s a collision)? In those cases, we’re keen to let users decide whether to configure this via analysis parameters than set some default behavior.

Pull Request analysis doesn’t make use of sonar.projectVersion at all

This should then be clarified in the documentation. It is quite unclear how it should be configured then, if even it should be. Shouldn’t it always be set to the tag version?

Hey again.

Looking at the description in the documentation… I don’t quite agree with it.

  • The project version. Is mandatory in case you use the new code definition based on the previous version.

It’s not strictly mandatory even if your New Code Definition is set to previous version. It’s useful, to reset the New Code Period, but analysis won’t fail without it. I’ll flag this for our documentation team.