Must-share information (formatted with Markdown):
- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
SonarQube Enterprise 8.9.6
- what are you trying to achieve
I would like to override my New Code Period global setting of “Previous Version” to be “Reference Branch” on certain branches within my projects, meanwhile maintaining “Previous Version” as the global setting.
- what have you tried so far to achieve this
I tried setting the option sonar.newCode.branchReference=master when using the sonar-scanner tool but it does not seem to be respected and the branch continues to use “Previous Version” as its New Code Period setting.
Am I misunderstanding the documentation on this? I expected this override to work based on the following.
Did you add this parameter after the branch was already under analysis? I believe this only kicks in on the first analysis of a branch. (And yes, the docs could probably be clearer about that.)
I confirmed that I am setting the sonar.newCode.referenceBranch option on the first push/analysis of the branch. I am still seeing the New Code period as previous version instead of comparing against the reference branch.
I just double-checked. You’re on the LTS. This feature was introduced in 9.4. That’s why it’s not working for you; you don’t have it.
I just realized that the docs incorrectly label 9.4 as the LTS (it’s not), but I saw that on the way to getting you the docs link for your version:
There’s currently an “out of date” label on these docs They’re not out of date (& we’ll get that fixed). They’re your reference for the version you’re using. So any time there’s a question, the 8.9 docs should be your guide.
That makes sense, you are correct that I do not see that analysis parameter in the 8.9 version.
Is there a way to accomplish the same thing in 8.9 in a different manner or do I just need to get our version of sonarqube upgraded?
In 8.9, the only way is to update an already-existing project branch. If you want to set via parameter on first analysis, you’ll need to upgrade.