Update Leak Period to last successful analysis

Hi Team,

SonarQube setups details:
-version = 7.4

  • quality gate = new code coverage
  • leak period = previous version

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.

How can I solve this issue. Any thoughts?

Hi,

Welcome to the community!

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:

7.4 → 7.9.6 → 8.9.3 → 9.2.1 (last step optional)

You may find the Upgrade Guide and the LTS-to-LTS Upgrade Notes helpful. If you have questions about upgrading, feel free to open a new thread for that here.

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.

 
Ann

Hi Ann,

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?

Regards,
Shreenath

Hi Shreenath,

Make sure you’re not passing a value that changes with each analysis (e.g. build number) as sonar.projectVersion.

If that doesn’t help, we can take this back up after you’ve upgraded to a supported version.

 
Ann

Hi Ann,
But if we are not updating the project_version for each analysis, how are we going to find the new code?

Shreenath