Sonarqube quality gate new code passes if re-run failed build

I have a Jenkins pipeline set up to trigger a SonarQube analysis for every build. The pipeline works as expected, failing the build if the quality gate is not passed. However, I noticed that if I rerun the build without making any changes to the code, SonarQube does not detect any new issues, and the quality gate passes. Is there a way to configure SonarQube to fail the quality gate even when there are no new changes in the codebase? I want to ensure that the quality gate is enforced consistently for all code, regardless of whether changes were made or not.

Any guidance on how to achieve this would be greatly appreciated. Thank you!

What did you try: I’ve already configured my Jenkins pipeline to trigger a SonarQube analysis for every build. Additionally, I’ve explored the settings within SonarQube but couldn’t find an option to enforce the quality gate on unchanged code.

What were you expecting: I was expecting that SonarQube would detect issues in unchanged code and fail the quality gate accordingly. However, even when I rerun the build without making any changes to the codebase, the quality gate passes as there are no new issues detected. I want to fail build in this case.

Hey there.

As noted in the template post – what version of SonarQube are you using?

version 10. community edition. Tested in latest one also but same issue.

Same issue but no perfect solution.