Maven SNAPSHOT and new code period

I’m using SonarQube Version 8.6 and I have a question about quality gates and new code periods. When using Maven, if an analysis is done on version 1.0.0-SNAPSHOT, SonarQube will then assume 1.0.0 is a new code period. is there any way to prevent this? I’m thinking a build without the -SNAPSHOT shouldn’t start a new code period.


It sounds like you’re using the previous_version setting for New Code Period. In that case, yes your New Code Period is going to change when the version string changes. There’s no semantic analysis of version strings to understand that 1.0.0 is related to 1.0.0-SNAPSHOT.


Hi Ann, yes thank you for the response.

So what I think the configuration I want then is “Reference Branch”. If I understand it correctly when SonarQube analyzes a feature branch, it will determine new code based off what’s in the reference branch, even if the version number in the feature branch changes. Does this sound correct?

However, this looks like an overall project setting. Meaning I cannot set feature/branch-1 to use “previous version” for new code and feature/branch-2 to use “reference branch” for new code?


For the reference branch option, it sounds like you have a correct understanding.

Keep in mind that you can set different New Code Periods per branch. Go to Project Settings → New Code and check the cog menu for each branch to get to those controls.

So you might set your main branch as the reference at the project level, and then go choose ‘Specific analysis’ (as an example) for your main branch.