- ALM used Bitbucket Cloud
- CI system used Bitbucket Cloud
- Scanner command used when applicable (private details masked)
- Languages of the repository: maven project
I can’t understand how we determine Previous version when we set new code definition to main branch or long-lived branch.
How it can detect the previous version? When I have a release version other than the main branch how it detects the previous version?
Could you please help me to understand it better ?
For short lived branch , the documention said that the report shows metrics only of the new code compared to the target branch. In this case what is the target branch?
“Previous version” is based on the
sonar.projectVersion value you pass in analysis. When that value changes, it marks a new version.
do you mean by you pass it in analysis, is adding in my pom file?
and how that variable gonna change , it will be manually or automatically?
and how the" previous version " works for long lived branches?
If you’re analyzing with Maven, then the project version is picked up automatically from your pom.
So I had to change the version so Sonarcloud can detect the new code ?
In case I have other released version and I’m updating the code on the same version without updating it, How SoanrCloud will detect the new code?
That’s a little bit backward. SonarCloud detects New Code because of your version. If you want to reset what’s detected as new code, then change your version. Or - to put things in the right order - when you change your version, SonarCloud detection of new code will reset.
Hi , THank you for your answer.
But how sonarcloud detect that the version got changed ? and when its detected, how he compare that ?
In case I have another released version (long-lived branches) and I’m updating the code on the same version without updating it, How SoanrCloud will detect the new code using previous code?
When you use the Scanner for Maven, it picks up most of your configuration from the Maven context / configuration / pom file. For instance, you don’t have to manually provide the project name or project key. Similarly, the version attribute from your pom file is used as the
It’s a simple string comparison with the version passed in the last analysis.
In case I 'm working on the main branch then I changed the version from 1.2 to 1.3 and run sonarcloud step (in bitbucket server) , how he can detect the new code,? because I think that the old code will change after I commits my changes
If you change the version string in your pom from “1.2” to “1.3” then - unless you’re overriding the value of
sonar.projectVersion - analysis will see that the string has changed, and that will mark a new version.
“New” code is what changes since that version string change.