Lesson 2 of 4 Pipeline Testing

Designing Quality and Release Gates

This lesson explains the difference between the two kinds of gate, including security and governance gates.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish quality gates from release gates.
  • Identify checks that act as release gates.
  • Explain security and governance gates.
  • Choose a gate from stated requirements.

Quality gates and release gates

The two terms describe a difference in position. A quality gate usually applies to code and build output, and it runs within a pull request or a build. It asks whether a change is good enough to proceed. A release gate applies at the entry to a stage or environment. It asks whether it is right to deploy now, and may consider things outside the code, such as active incidents or a change window.

A gate should be automatic whenever a rule can be expressed, because a person who approves dozens of routine releases stops looking carefully. A manual approval is justified where human judgment adds something, such as a business decision on timing.

Sort into groups

Quality gate or release gate?

Exam skills 3.2.1

Decide whether each condition is a quality gate or a release gate.

Log in to try this activity Interactive activities are free with an account.

Quality gates in practice

Quality gates appear as required checks on a pull request, or as steps that fail a run. Typical conditions include the following.

  • All required tests pass.
  • Code coverage on changed code meets a threshold.
  • Static analysis and linters report no new high-severity issues.
  • Dependency and secret scans find nothing blocking.
  • Infrastructure templates pass validation and policy checks.

Gates should be strict about new problems and more tolerant of old ones. A rule that fails every build until 3,000 historic issues are fixed will soon be switched off. A rule that blocks only new issues improves quality steadily without stopping delivery.

Scenario questions

Gates that teams keep

Exam skills 3.2.1

Design quality gates that improve quality without stopping delivery.

Log in to try this activity Interactive activities are free with an account.

Release gates with environment checks

In YAML pipelines, release gates are implemented as checks on an environment, or on another protected resource such as a service connection. The lesson on checks and approvals explains the full list. The checks commonly used as gates are as follows.

CheckWhat it asks
Query Azure Monitor AlertsAre any matching alerts active?
Invoke REST APIDoes an external system, such as change management, approve?
Invoke Azure FunctionDoes custom logic allow the release?
Business hoursIs it within the allowed time window?
Evaluate artifactDoes a container image meet a policy?
Required templateDoes the pipeline extend an approved template?
ApprovalsHas a named person agreed?

Checks can be re-evaluated at intervals until they pass or a timeout expires. This allows a gate to wait for a condition, such as an alert clearing, rather than failing at once. In GitHub, environments offer required reviewers, wait timers and branch restrictions, and custom deployment protection rules use a GitHub App to call external systems.

The following diagram shows a Query Azure Monitor Alerts check holding or releasing a production stage.

A Query Azure Monitor Alerts check on the production environment. Before the stage starts, the check queries active critical alerts, retrying at an interval until a timeout; it holds the release while alerts are active and lets it proceed once they clear, with nobody watching.
The scenario is illustrative.
Match the pairs

Environment checks as release gates

Exam skills 3.2.1 · 3.3.9

Match each environment check with the question it answers.

Log in to try this activity Interactive activities are free with an account.

Security and governance gates

A security gate makes a vulnerability a reason to stop. Examples include a required AdvancedSecurity/NewHighAndCritical status check in Azure Repos, a dependency review on GitHub pull requests, and a pipeline step that fails on a critical container image finding.

A governance gate confirms that a process has been followed. A Required template check proves that a pipeline runs mandatory steps, so a team cannot remove a scan from its own YAML. Azure Policy enforces rules at the Azure level: even a pipeline that passes every gate cannot create a resource that violates a Deny policy, which gives a final layer of control. Audit requirements are met by the record of approvals and checks kept in each run.

True or false

Security and governance gates

Exam skills 3.2.1

Check how security and governance gates enforce rules.

Log in to try this activity Interactive activities are free with an account.
Worked example

Preventing release during an incident

A team deploys with a multi-stage YAML pipeline in Azure Pipelines. During a recent outage, a scheduled release went to production and made diagnosis harder. Releases must wait while critical alerts are active, without anyone having to intervene. What should you configure?

Add a Query Azure Monitor Alerts check to the production environment, with suitable filters and a retry interval and timeout. The check holds the stage while alerts are active and allows it when they clear. A manual approval would need someone to watch for incidents. A step inside the YAML could be changed or removed by the pipeline author, and it would run after the deployment job had begun, whereas a check on the environment is applied before the stage starts.

Check yourself

Why is a check on an environment stronger than a step in the YAML?

Show answer

The environment owner sets a check, so a pipeline author cannot remove it, and it applies before the stage starts.

Exam Tips

Remember for the exam

  • A quality gate judges the change; a release gate judges whether to deploy now.
  • Automate gates where a rule can be stated.
  • Block new high-severity issues rather than all historic ones.
  • Environment checks are the YAML form of release gates.
  • Required template proves that mandatory steps cannot be removed.