What is a quality gate in a CI/CD pipeline?

BeginnerConceptCI/CD practices
Answer

In one line: A quality gate is an automatic checkpoint in the pipeline that stops the code from moving forward unless it meets agreed standards — such as all tests passing, enough test coverage, or no critical vulnerabilities.

Common quality gates:

  1. Build and unit tests pass.
  2. Code coverage above a threshold (for example 80% on new code).
  3. Static code analysis — SonarQube quality gate: no new bugs, code smells or security hotspots above a limit.
  4. Security scans — no critical/high vulnerabilities in dependencies (SCA) or container images; no secrets found.
  5. IaC policy checks — Checkov or OPA rules pass (no public S3 buckets, encryption on).
  6. Integration / end-to-end tests pass in the test environment.
  7. Performance — response time under an agreed limit in a load test.
  8. Manual approval — for production, when required.

How it blocks the pipeline: the step returns a non-zero exit code, so the job fails and later stages don't run.

# Fail if any critical vulnerability is found
trivy image --severity CRITICAL --exit-code 1 orders:1.4.2

In SonarQube, the scanner can wait for the quality gate result and fail the build if it's red.

Good practices:

  • Gate on new code, not the whole legacy codebase — otherwise old problems block every change.
  • Start soft, then strict — report-only at first, then block once the team has cleaned up.
  • Keep gates fast so developers get feedback quickly.
  • Allow documented exceptions for false positives, with an owner and an expiry date.

Example: a team's PR pipeline blocks merges if unit tests fail, coverage on new code is below 80%, or Trivy finds a critical CVE with a fix available.

Tip for interviews: say which gates you set, the thresholds, and how you handled false positives.

All DevOps Fundamentals questions

More on CI/CD practices