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.
Your New Code Period is resetting on each analysis. This can happen if you have it set to “previous version” and pass a new sonar.projectVersion with every analysis, instead of just on new releases.
You’re expecting the Quality Gate to fail on Overall Code conditions, which is not the default behavior (you have to add those conditions, keeping in mind that this is contrary to the Clean as You Code methodology)