Skip to content
Latchkey

SonarQube "Quality Gate failed" in CI

Analysis ran successfully but the project breached a Quality Gate condition (coverage on new code, duplications, new issues, or security rating). With the gate enforced, the action returns a failure status.

What this error means

The Sonar step or the quality-gate wait action reports "QUALITY GATE STATUS: FAILED" and lists which conditions failed, such as "Coverage on New Code is less than 80%".

SonarQube
QUALITY GATE STATUS: FAILED - View details on https://sonarcloud.io/dashboard?id=my-project
Failed conditions:
  Coverage on New Code 62.0% is less than 80%

Common causes

New code does not meet a gate condition

The default "Clean as You Code" gate checks coverage, duplications, and new issues on changed code; falling below a threshold fails the gate.

Coverage was not imported, so it reads as 0%

If the coverage report is not passed to the scanner, Sonar treats new code as 0% covered and the gate fails on that condition.

How to fix it

Address the failing condition the gate names

  1. Open the dashboard link and read which condition failed on new code.
  2. Add tests or fix the new issues so the changed lines meet the threshold.
  3. Push again; the gate re-evaluates on the new analysis.

Import the coverage report into the scan

Point the scanner at your generated coverage so it does not assume 0% on new code.

sonar-project.properties
# sonar-project.properties
sonar.python.coverage.reportPaths=coverage.xml
sonar.javascript.lcov.reportPaths=coverage/lcov.info

How to prevent it

  • Generate and import coverage before the Sonar scan, not after.
  • Review the gate conditions so the team knows the coverage bar on new code.
  • Fix new issues in the PR rather than letting them accumulate.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →