QualityGate Fail After Making Code Change

The first sonarqube quality gate analysis is successful, but then when I make a few code changes and perform the analysis again, the quality gate fails and the new code covarege 0 appears.

I m using SonarQube Community Edition v 9.1 and integrate jenkins.
I am sharing screenshots of the problem, I would be very happy if you could help.

First analaysis

after making some changes


Hi,

The Quality Gate always succeeds on first analysis because there’s nothing to compare it to. On subsequent analyses all your changes will be in the New Code Period and tested by the Quality Gate(QG) conditions. The default QG includes a requirement for test coverage and you’re apparently not passing in any test coverage reports. Thus the QG fails on the 2nd analysis.

 
HTH,
Ann

2 Likes

Hi Ann,

Thanks for the reply. Do you have any suggestions for solving the problem? Does it need to be modified on the code side or is it due to the Sonarqube configuration? I don’t quite understand this point.

Hi,

You’re failing the Quality Gate for 0% Coverage on New Code. Did you write tests for the lines you changed? That’s the first step. If you’ve already done that, did you run tests as part of your build? Generate a coverage report? Feed the report into your SonarQube analysis? Those are the steps to resolving this.

 
:slight_smile:
Ann