Skip to content
Latchkey

SonarQube "QUALITY GATE STATUS: FAILED" in CI

The scanner ran and uploaded fine. With -Dsonar.qualitygate.wait=true, the scanner then polled the server, the quality gate evaluated your conditions, and at least one failed. The step exits non-zero and prints which conditions failed.

What this error means

The scanner finishes analysis, then prints "QUALITY GATE STATUS: FAILED" followed by one or more failing conditions (coverage, duplications, new issues). The job fails only when sonar.qualitygate.wait=true.

sonar-scanner
QUALITY GATE STATUS: FAILED - View details on https://sonarcloud.io/dashboard?id=my-project
Failed conditions
  62.4% Coverage on New Code (required >= 80%)
  4.1% Duplicated Lines on New Code (required <= 3%)
ERROR: QUALITY GATE STATUS: FAILED

Common causes

New-code conditions are stricter than overall code

The default Sonar way gate measures new code only. A change with low coverage or new duplication fails even when the whole project looks healthy.

The gate is configured to wait and block the pipeline

With sonar.qualitygate.wait=true (or the wait action), a failing gate returns a non-zero exit code and stops the job by design.

How to fix it

Read the failing conditions and address the new code

  1. Open the dashboard URL the scanner printed and read the Failed conditions list.
  2. Add tests to raise Coverage on New Code, or refactor to reduce Duplicated Lines on New Code.
  3. Resolve any new bugs, code smells, or vulnerabilities the gate flags.
Terminal
# run analysis and wait for the gate result
sonar-scanner -Dsonar.qualitygate.wait=true

Adjust the gate threshold if it is genuinely wrong

If a threshold is unrealistic for this project, change it in Project Settings > Quality Gates on the server. Do not silence the gate in CI; keep the failure visible.

How to prevent it

  • Write tests alongside changes so Coverage on New Code stays above the threshold.
  • Review the specific failing conditions rather than the overall project rating.
  • Keep the gate definition in the server, versioned by your platform team.

Frequently asked questions

What causes ""QUALITY GATE STATUS: FAILED""?
The default Sonar way gate measures new code only. A change with low coverage or new duplication fails even when the whole project looks healthy.
How do I fix "QUALITY GATE STATUS: FAILED"?
Read the failing conditions and address the new code

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card