New Project Version does not stick at date, gets pushed to latest analysis

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube Server / Community Build, Scanner, Plugin, and any relevant extension)
    sonarqube-server/10.7/
    using it for a Kotlin/Java Android App through gradle command sonar

  • how is SonarQube deployed: zip, Docker, Helm
    I don’t know; IT set it up

  • what are you trying to achieve
    Using New Code to scope Quality Gates to the latest version.
    For this to work, we are sending the property “sonar.projectVersion”, “${newCodeVersion}” to sonarqube. We can confirm the version is being sent as it appears in the activity tab.
    The problem we are running into is that the first occurrence of a version is not marking new code properly; instead, the version is moved by every analysis to the newest analysis instead of staying in place as a marker.

  • what have you tried so far to achieve this
    I also tried manually adding the version event on Jan 10th, but after some time it disappeared there and was seemingly overwritten with the newest entry again.

Version 32.03 was first sent to sonar (and appeared properly) on January 10th. But with each sync, it got pushed to the newest entry, so we don’t get to use the feature properly.

It got moved after the latest sync/analysis:

Hi,

This is working as designed. It’s just that the design is very 2008-Maven-centric. :smiley:

The idea is that the version string changes at release, and then your Quality Gate compares against all the changes since that release. Every time you send the same version string in with a new analysis, you’re saying “no new release yet, just add these changes to what you’re considering as new”.

It’s at release, when the sonar.projectVersion string value changes, that you reset the new code period.

So what you’re seeing in the Activity tab is an indication of the most recent analysis to use the same version string. Here’s an example from our dogfood server

So when you set your New Code definition to ‘previous version’, you’re comparing everything that’s used the 32.03 version string to the state of the code before you changed the string.

Does that help?

 
Ann

Ah ok I get it now.

So when we finally set our version to the next one, the one that currently was pushed forward will stay and mark new code. I guess we will have to review the timing of when we update this version string in our codebase.

Thanks

1 Like