Enforce build quality gates for prod deployments
π― Goal: your CI attaches coverage and vulnerability results to every build, and production deploys check them on their own. A build with at least 80% line coverage and no critical vulnerabilities deploys with nobody involved. One that falls short stops, tells the developer exactly which gate failed, and only goes out if an admin grants a recorded exception.
Introductionβ
Quality standards that live in a wiki get applied when someone remembers. Standards that live in CI get applied, but only to the repositories whose pipeline someone kept up to date, and a failed check in CI doesn't stop a deploy that happens later from a different place.
Nullplatform moves the decision to where the risk is: the production deploy. Your CI reports what it measured, and the deploy reads it:
- Your CI publishes facts, not verdicts. Each build carries its coverage and vulnerability counts as catalog metadata. The pipeline doesn't decide anything, so changing a threshold never means editing every repository
- A checklist turns those facts into gates. Conditions evaluate the moment the deploy is requested, so the developer sees the result before anyone is asked for anything
- Exceptions are deliberate. When a hotfix has to ship below the bar, an admin overrides the gate with a written justification. The run records that the deploy went out despite a failed gate, and who decided it
A technology template ties it together: every new application starts from a pipeline that already reports these metrics.
What you'll set upβ
- Two catalog specifications on the
buildentity:coverageandsecurity - A technology template whose CI publishes both to every build
- A checklist on production deploys with two blocking conditions, one informational condition, and one override
- Automatic execution for builds that pass every gate
Prerequisitesβ
- Checklists enabled in your organization (early release)
- An
environmentdimension with aproductionvalue - Access to your GitHub organization, to create a template repository
- One of these, depending on how you want to work:
- Coding assistant: the np-api and np-checklist skills, part of the nullplatform AI plugins. See Set up the AI plugins
- Infrastructure as code: Terraform or OpenTofu with the nullplatform provider v0.0.106 or later, and an API key with the
adminrole at organization level
Step 1: Declare what a build reportsβ
Declaring the metadata first means every build is validated against the same shape, so a typo in one pipeline fails loudly instead of quietly slipping past the gate.
- Coding assistant
- Terraform
- API
/np-api create two metadata specifications for builds in my account:
"coverage", with lines.percent (number from 0 to 100, required) and an
optional report URL; and "security", with critical and high (non-negative
integers, both required) and an optional report URL.
resource "nullplatform_metadata_specification" "coverage" {
name = "Coverage"
description = "Test coverage reported by CI"
nrn = "organization=1:account=2"
entity = "build"
metadata = "coverage"
schema = jsonencode({
type = "object"
properties = {
lines = {
type = "object"
properties = {
percent = { type = "number", minimum = 0, maximum = 100 }
}
required = ["percent"]
}
report = { type = "string" }
}
required = ["lines"]
additionalProperties = false
})
}
resource "nullplatform_metadata_specification" "security" {
name = "Security"
description = "Vulnerability counts reported by CI"
nrn = "organization=1:account=2"
entity = "build"
metadata = "security"
schema = jsonencode({
type = "object"
properties = {
critical = { type = "integer", minimum = 0 }
high = { type = "integer", minimum = 0 }
report = { type = "string" }
}
required = ["critical", "high"]
additionalProperties = false
})
}
Send one POST request per specification. The coverage one:
curl -L 'https://api.nullplatform.com/metadata/metadata_specification' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <token>' \
-d '{
"name": "Coverage",
"description": "Test coverage reported by CI",
"nrn": "organization=1:account=2",
"entity": "build",
"metadata": "coverage",
"schema": {
"type": "object",
"properties": {
"lines": {
"type": "object",
"properties": { "percent": { "type": "number", "minimum": 0, "maximum": 100 } },
"required": ["percent"]
},
"report": { "type": "string" }
},
"required": ["lines"],
"additionalProperties": false
}
}'
And the security one:
curl -L 'https://api.nullplatform.com/metadata/metadata_specification' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <token>' \
-d '{
"name": "Security",
"description": "Vulnerability counts reported by CI",
"nrn": "organization=1:account=2",
"entity": "build",
"metadata": "security",
"schema": {
"type": "object",
"properties": {
"critical": { "type": "integer", "minimum": 0 },
"high": { "type": "integer", "minimum": 0 },
"report": { "type": "string" }
},
"required": ["critical", "high"],
"additionalProperties": false
}
}'
The name of each specification is the key the build's metadata lives under, which is what the checklist reads later: build.metadata.coverage.lines.percent and build.metadata.security.critical.
β Checkpointβ
Open any build in the nullplatform UI: its catalog lists the coverage and security sections, still empty.
Step 2: Make your CI report them on every buildβ
The metrics have to come from the pipeline, and the cheapest way to get every team's pipeline to report them is to put it in the template new applications start from.
-
Create a namespace for your templates, for example Technology Templates, and create an application in it from the standard Any Technology template.
-
In GitHub, mark the new repository as a template and clone it.
-
Add two files at the root that stand in for your real scanners' output. In your own pipeline, generate them from your coverage and security tools instead:
coverage.json{
"coverage": {
"lines": { "percent": 87 }
}
}security.json{
"security": { "critical": 0, "high": 2 }
} -
Replace the CI workflow so it publishes both files to the build:
.github/workflows/ci.ymlname: ci-nullplatform
env:
NULLPLATFORM_API_KEY: ${{ secrets.NULLPLATFORM_API_KEY }}
on:
push:
branches:
- main
permissions:
id-token: write
contents: read
packages: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install nullplatform CLI
run: curl https://cli.nullplatform.com/install.sh | sh
- name: Add CLI to PATH
run: echo "$HOME/.nullplatform/bin" >> $GITHUB_PATH
- name: Create build on nullplatform
run: np build start
- name: Build Docker image
run: docker build -t my-app .
- name: Push Docker image
run: np asset push --type docker-image --source my-app
- name: Report coverage
run: np metadata create --entity build --data "$(jq -c . coverage.json)"
- name: Report vulnerabilities
run: np metadata create --entity build --data "$(jq -c . security.json)"
- name: Set the build as successful
if: success()
run: np build update --status successful
- name: Set the build as failed
if: failure() || cancelled()
run: np build update --status failedThe CLI finds the build from the repository and commit it runs in, so there's no build id to pass around.
-
Push the changes.
Step 3: Register the templateβ
Register the repository as a technology template so developers can pick it when they create an application.
- Terraform
- API
resource "nullplatform_technology_template" "golang" {
name = "Golang 1.17.9"
url = "<github_template_url>"
account = <account_id>
provider_config = {
repository = "technology-templates-golang"
}
components {
type = "language"
id = "google"
version = "1.17"
metadata = jsonencode({
"version": "1.17.9"
})
}
tags = ["golang", "backend"]
metadata = jsonencode({})
rules = jsonencode({})
}
Send a POST request:
curl -L 'https://api.nullplatform.com/template' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <token>' \
-d '{
"name": "Golang 1.17.9",
"organization": <org_id>,
"account": <account_id>,
"url": "<github_repository_url>",
"provider": {
"repository": "technology-templates-golang"
},
"components": [
{
"type": "language",
"id": "google",
"version": "1.17",
"metadata": { "version": "1.17.9" }
}
],
"rules": {},
"metadata": {},
"tags": ["golang", "backend"]
}'
β Checkpointβ
Create an application from the template in another namespace and push a commit. When the build finishes, its catalog shows coverage.lines.percent: 87 and security.critical: 0.
Step 4: Gate production on those numbersβ
Now the checklist that reads them on every production deploy:
- Coding assistant
- Terraform
/np-checklist create a checklist named production-quality-gates:
- A blocking condition "Line coverage at least 80%" on
build.metadata.coverage.lines.percent.
- A blocking condition "No critical vulnerabilities" on
build.metadata.security.critical equal to 0.
- An informational condition "No high vulnerabilities" on
build.metadata.security.high equal to 0, so reviewers see it without it
blocking.
- An override "Quality exception" that requires a comment and can only be
granted by an admin who isn't the requester. Its description should say
it's for urgent fixes that can't wait for the build to meet the bar.
Set execution_trigger: automatic_approval, and connect it to
deployment:create in production across my account.
resource "nullplatform_checklist_specification" "production_quality_gates" {
nrn = "organization=1:account=2"
name = "production-quality-gates"
definition = jsonencode({
execution_trigger = "automatic_approval"
items = [
{
id = "coverage_gate"
type = "condition"
behavior = "gate"
severity = "major"
title = "Line coverage at least 80%"
query = { "build.metadata.coverage.lines.percent" = { "$gte" = 80 } }
},
{
id = "no_critical_vulnerabilities"
type = "condition"
behavior = "gate"
severity = "critical"
title = "No critical vulnerabilities"
query = { "build.metadata.security.critical" = { "$eq" = 0 } }
},
{
id = "no_high_vulnerabilities"
type = "condition"
behavior = "informational"
severity = "minor"
title = "No high vulnerabilities"
query = { "build.metadata.security.high" = { "$eq" = 0 } }
},
{
id = "quality_exception"
type = "manual"
behavior = "override"
title = "Quality exception"
description = "For urgent fixes that can't wait for the build to meet the bar. Explain why in the comment."
require_comment = true
validations = [
{
id = "four_eyes"
message = "Someone other than the requester must grant the exception."
rule = { "actor.user_id" = { "$ne" = "$approval.requested_by" } }
},
{
id = "admin_role"
message = "Only admins can grant a quality exception."
rule = { "actor.effective_roles" = { "$in" = ["admin"] } }
}
]
}
]
})
}
resource "nullplatform_approval_action" "production_deploys" {
nrn = "organization=1:account=2"
entity = "deployment"
action = "deployment:create"
dimensions = {
environment = "production"
}
}
resource "nullplatform_approval_action_checklist_specification_association" "production_deploys" {
approval_action_id = nullplatform_approval_action.production_deploys.id
checklist_specification_id = nullplatform_checklist_specification.production_quality_gates.current_version_id
}
What each behavior does here:
gateitems stop the deploy when they fail. These are your non-negotiables.informationalreports without ever blocking. High-severity findings show up on every deploy, so reviewers and developers see the trend before you decide to make it a gate.overrideonly comes into play once a gate has failed. Granting it doesn't turn the failed gate green: the run resolves asapprove_with_override, so the record keeps both facts, that the build fell short and who let it through anyway.
automatic_approval starts the deploy on its own when only conditions decided the run, which is every build that meets the bar. A deploy that needed an exception waits for the developer to press Start deployment, so the person shipping below the bar chooses the moment.
An approval action runs on a checklist or on policies, never both. If your production deployment:create action already has policies attached, the connection fails with a 409. Reach out to the nullplatform team to move it onto a checklist.
β Checkpointβ
Dry-run it against both sides of the threshold, without producing a single failing build:
dry-run production-quality-gates with coverage at 72% and 0 critical
vulnerabilities, then with coverage at 91%
At 72% the coverage gate fails and the exception is available. At 91% every gate passes and the run approves on its own.
Step 5: Deploy to productionβ
Create a release from a build of your templated application and deploy it to a production scope. Then lower percent in coverage.json, push, and deploy the new build to see the other side.
β Checkpointβ
The passing build deployed on its own. The 72% build stopped with the coverage item naming the value it read, and an admin's exception let it through with the run reading approve_with_override.
Make it yoursβ
- Raise the bar without touching a pipeline. Thresholds live in the checklist, not in CI. Publish a new version with 85% and every repository is held to it from the next deploy, while past runs keep the version they were judged against.
- Promote a signal when you're ready. Run a new check as
informationalfor a few weeks, watch how often it would have blocked, then make it agate. - Apply different bars per environment. Connect the same spec to staging with an
applies_whenon the stricter items, so staging reports what production would enforce. - Add the human checks too. The PCI sign-off fits in this same spec, so one production checklist holds both kinds of guardrail.
What's nextβ
- Require stage deployment before production: make every build prove itself in stage first, checked by a workflow
- Match approval friction to deploy risk: replace fixed thresholds with a risk score for each change