I have the Developer Edition Version 9.1 (build 47736)
I have the next new code config
This is the activity of my project
And the new code is compared with the version from the project creation.
But I need the new code will compare with the last version (I create a new version every week since the beginning). Anyone can help me…
Welcome to the community!
The Reference Branch New Code Period setting is going to count as new code everything that changed since your branch diverged from the reference.
I guess you’re rebasing your branches against the main branch each week after you release the new version? For what you want, it doesn’t sound like there’s a perfect solution. Probably the ‘specific analysis’ option (docs) is going to be best here. After you rebase, I’m assuming that triggers a build/analysis. So then you need to set that analysis of the rebase as the baseline for each branch.
Or have I misunderstood the situation?
Also, would you mind explaining for our edification how you use these other, non-main branches?
Currently, I have the master main branch. from this branch, I create new features branches like the Git Flow strategy. when the feature is done we create a PR to merge this into master.
There are every week merges to master and QA branches.
And the QA branch has the right behavior but the master branch not
If everything’s working right except the main branch, and you want the main branch to reset the New Code period with each week’s release, then I would edit the New Code Period setting for just that branch, specifically and explicitly (from your first screenshot, use the cog menu on the ‘master’ branch row) to ‘Preview version’
i guess you meant ‘Previous version’ !?
The main branch has already this setting, which could be seen in the screenshot
of the first posting.
We use the same settings for our legacy projects with a quality gate that has only new conditions.
Maybe the problem is a difference of new code between PRs and main branch <-> previous version.
@handresc1127 Are those issues on the main branch always from specific rules ?
Yes. Thank you. I meant “Previous version”. I guess my hands were on autopilot. And thanks for directing my attention back to the screenshots in the OP. I also didn’t scroll back up enough when composing my last reply.
@handresc1127 you’ve said you change version every week. How do you change version? You are changing the value that’s fed into the
sonar.projectVersion analysis parameter, right?
Ohhh! I had never changed the sonar.projectVersion may be this is the problem
I’m going to check that and come back.
Hi community sorry for the delay, but I was waiting for the new release to the master branch in order to confirm the solution.
It is working right now!
The solution was to include the sonar.projectVersion=$(Build.BuildNumber) in my azure pipeline
That’s probably not what you wanted to do. By feeding build number into
sonar.projectVersion you’re going to set a new version with ever build. Unless you only build once a week (really?) you’re going to get a version change that’s far too frequent.