Managing "new code" for main and release branches

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Developer Edition
    v10.6 (92116)

  • how is SonarQube deployed: zip, Docker, Helm
    running on VM

  • what are you trying to achieve
    Appropriate definition of new code for a LTS release branch and our current main branch.
    We recently upgraded and switched to clean as you code. We have 2 nightly builds, 1 for our LTS and one for our main branch that go to the same Sonar project. Our goal is that the LTS reports new code against the last released version of the LTS, and that main’s new code definition is against the most recent release (i.e. not our LTS).

  • what have you tried so far to achieve this
    We are configured for previous version right now. Our understanding of the documentation was that the version should be read from the pom file, and therefore for main, it would go to the previous non-snapshot version relative to what’s in the POM (which is a major version ahead of our LTS), and that the LTS would declare new code as since the last LTS release.

What’s happening is that main appears to show new code since the LTS? Based on the label on the overview page which states New Code:Since next-LTS-version-SNAPSHOT rather than New Code:Since current-in-progress-version-SNAPSHOT

Our main branch nightly pipeline runs several hours before the LTS. Is that part of the reason this is happening?

Do we need to switch to Reference branch for the LTS and/or main?

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Hi,

Your previous version setting should do this.

To be clear, you’re releasing from main, and you want main’s new code to be compared to main’s previous version, rather than versus a release branch, right? If so, previous version should work for that too. (Side note, each branch can have a different new code definition, so it would be possible to use previous version for your LTS branch and something else for main.)

So… the thing to know about using previous version is that the version string analysis is picking up from your pom is just that: a string. So for example, going from 1.2-snapshot to 1.2 is a “new version”. There’s nothing more sophisticated than that. No version parsing & no understanding that 1.2-snapshot and 1.2 are essentially the same thing. When the string changes, it’s a new version.

Does that help?

 
Ann

The behavior you are describing is what I was expecting. I think part of our issue was that we did a manual scan of the LTS but had it accidentally configured to be “main”

1 Like