Diagnosing and Fixing Qodana Quality Gate Failures in CI Pipelines
When Qodana quality gates fail in CI, the culprit is often a mis‑configured threshold or a mismatch between local and CI settings. This guide walks through the recognizable symptoms, diagnostic checks, and targeted fixes to get builds passing again.
11 Jul 2025, 19:45 UTC

Problem Statement
When Qodana runs in a CI pipeline, a build may fail even though the inspection output looks acceptable. The most common culprit is a mis‑configured quality gate that is too strict or incorrectly referencing inspection metrics.
Recognizable Condition
- CI job logs contain a line such as
Quality gate failed: 4 defects found, threshold 2. - The
.qodana/quality-gates.yamlfile exists but shows unexpected threshold values. - Local
qodana analyzeruns finish with exit code1while the inspection report is otherwise clean.
Cause & Diagnostic Table
| Cause | Diagnostic Check | Potential Fix |
|---|---|---|
| Threshold too low for current codebase. | Open .qodana/quality-gates.yaml and review maxAllowed values. | Increase thresholds to match realistic defect counts. |
Metric name mismatch (e.g., bug vs defect). | Verify that the metric keys in the YAML match those reported by Qodana. | Rename keys or adjust the YAML to use correct metric identifiers. |
| Custom inspection missing or mis‑packaged. | Check that all custom inspection JARs or XML files are present in .qodana/inspections and referenced in inspections.xml. | Add missing files or correct the reference paths. |
| Docker image mismatch. | Ensure the CI runner uses the same Qodana Docker image version as local analysis. | Pin the Docker image tag in the CI job definition. |
| Inspection profile not applied. | Run qodana analyze --profile=custom locally and confirm the profile is used. | Add profile flag to CI job or set profile in qodana.yml. |
Ordered Checks
- Inspect the Quality Gate File
Runcat .qodana/quality-gates.yamlin the repo root. Look for sections like:
Check that each key matches the metrics reported by Qodana.maxAllowed: bug: 2 vulnerability: 0 codeSmell: 5 - Verify Inspection Results Locally
Executeqodana analyze --output=reportwith the same Docker image used by CI. After completion, runqodana analyze --exit-codeto see if the exit code is0or1. A non‑zero code indicates a gate failure. - Cross‑Check CI Log
Search the CI job log for the lineQuality gate. The log will show the actual counts and the thresholds used. If the numbers differ from the local run, the CI job is using a different configuration. - Confirm Docker Image Consistency
In the CI job definition (e.g., GitHub Actionsruns-onor GitLabimage), ensure the tag matches the local version:docker run --rm -v $(pwd):/project jetbrains/qodana:jdk17-2025.2.1 analyze - Check Custom Inspection Packaging
If you use custom inspections, runqodana --list-inspectionslocally to confirm they are detected. In CI, ensure the.qodana/inspectionsdirectory is committed and referenced.
Fixes Tied to Findings
- Adjust thresholds: Edit
quality-gates.yamland bumpmaxAllowedvalues. Commit and push. - Correct metric keys: Replace
bugwithdefectif that is the metric Qodana reports. - Add missing custom inspections: Place the XML file in
.qodana/inspectionsand reference it ininspections.xml. - Pin Docker image: In CI YAML, replace
jetbrains/qodana:latestwithjetbrains/qodana:jdk17-2025.2.1. - Apply the correct profile: Add
--profile=customto theqodana analyzecommand in CI.
Escalation Criteria
- If after all adjustments the build still fails, verify that the failure originates from the quality gate step and not from a preceding analysis error.
- Check the Qodana release notes for any changes to metric names or default thresholds that might affect your configuration.
- Consult the Qodana community or support if the issue persists after aligning configuration, Docker image, and inspections.
Limitations and Practical Check
Quality gates are static; they do not account for context such as temporary workarounds or intentional code smells. A gate failure should prompt a review of the specific defects rather than a blanket threshold increase.
To confirm a fix, run qodana analyze --exit-code locally after each change. A zero exit code confirms the gate passed. In CI, re‑run the job and verify the Quality gate step shows passed and no error lines.
Conclusion
By systematically inspecting the quality gate file, matching local and CI outputs, and ensuring consistent Docker images and inspection packaging, you can quickly identify and resolve the most common causes of Qodana quality gate failures. This diagnostic loop keeps the pipeline stable while maintaining code quality standards.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.