Issue:
In the first go after a commit, if quality gate does not pass, build is breaking. But if I run the sonar analysis on the same code again, it passes.
I think the possible explanation for this is that when the analysis ran for the first time, it updated the current version and the code in sonar is changed to the current code which has uncovered lines.
When I run the sonar analysis again, it compares with the last version which was effectively the exact same code and thus it does not find any new code this time, and as a result quality gate passes.
First, your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:
Regarding your question, it seems that you’re either using the Since Previous Analysis setting for the leak/New Code Period, or you’re using previous_version, and passing a new value for sonar.projectVersion with each analysis. We’ve made changes to the New Code Period since 7.4. If you still have questions after the upgrades, come back to us.
Yes we are using the leak period as previous_version. And we are updating sonar.projectVersion with each analysis.
My problem is that second time it is passing the build which is defeating our purpose of doing analysis on new code.
Could you please suggest how we can stop this from happening?