The three build gates
The build Job of an application is generated from its component. Its gates run as init containers in front of the builder, on the exact commit the builder will build. When a gate enforces and fails, the builder never starts: there is nothing to roll back, because nothing was pushed.
The build Job, in order
Every application component of type external_source_code renders k8s/build/base/<app>/ with one
Job (BuildKit or Kaniko, by the stack's build_type). The containers run in this order:
| # | Container | Runs when | What it does |
|---|---|---|---|
| 1 | source-gate | build_gate is enforce or report | Clones the branch, scans the build context for secrets and for CRITICAL vulnerabilities that already have a fix in the dependency manifests (Trivy) |
| 2 | sast-gate | sast_gate is enforce or report | Clones the branch, runs your pattern rules (Opengrep) over the exact tree |
| 3 | sonar-gate | the sonarqube-<app> link has enforce_quality_gate: true | Analyses the exact commit in SonarQube and waits for the quality gate |
| 4 | builder | always | Builds and pushes <registry>/<app>:<version> |
| 5 | rollout | push_and_deploy is not false | Writes the pushed digest onto the Deployment and waits for the roll |
Gate 1 — the source scan (build_gate)
| Value | Behaviour |
|---|---|
enforce | Any finding, or a scanner that could not run, fails the Job: the image is not built (fail closed) |
report | The same findings are printed; the build always continues |
off | The container is not rendered |
Two scans run: trivy fs --scanners secret over the build context, and trivy fs --scanners vuln --severity CRITICAL --ignore-unfixed over the dependency manifests. The secret scan needs no
registry and cannot be stopped by a rate limit; the vulnerability scan resolves manifests online, and
when the registry refuses, that part is reported as a warning rather than a block — the running image
is still scanned by the Trivy operator. A finding exits with code 3; any other non-zero exit is a
scanner error and is never reported as a finding.
Gate 2 — your own rules (sast_gate, sast_rules, sast_version)
The pattern gate runs Opengrep (LGPL-2.1) with a baseline
rule set shipped in the gate image (sast_version, a full image reference you can pin) plus the
rules you type into sast_rules — Semgrep-syntax YAML, one textarea on the application. A
.opengrep/ directory in the repository is picked up too. This is where a team writes the rule
nobody else can write for them: "no permitAll() in our Spring security config", "no unescaped
th:utext", "this internal client must not be called from a controller".
| Exit | Meaning | Job behaviour |
|---|---|---|
| 0 | passed | continues |
| 2 | findings, or rules that do not load | fails at once, no retry (a retry would rescan the same commit) |
| 1 | clone or scanner failure | retried like any build failure |
report prints the same lines and always continues. The gate's own message tells you the attribute
to change if you must build without it.
Gate 3 — the quality gate (sonarqube-<app> link)
The sonarqube component provisions one project and one analysis token per linked application (its
bootstrap Job, on every apply). With scan_enabled only, a separate <app>-sonar-scan Job analyses
the code after the build and reports. With enforce_quality_gate: true on the link, the analysis
becomes the sonar-gate init container: it analyses the exact commit the builder will build and
waits for the quality gate. Once SonarQube has taken the project over (gate stacktic-managed, new
code counted from the first gated analysis), new bugs or vulnerabilities on new code push nothing.
| Verdict line | Meaning |
|---|---|
sonar-gate: passed | the quality gate is OK for this commit |
sonar-gate: FAILED | the gate failed; nothing built or pushed; no retry |
sonar-gate: NO VERDICT | clone, compile or SonarQube unavailable; the Job retries |
sonar-gate: NOT ENFORCED | the project is not set up yet (first build) or not managed yet; the build continues |
Java sources with a pom.xml are compiled for the analysis (mvn clean compile), so the gate sees
bytecode, not just text.
What the stack agent keeps
The Job is removed after its TTL; its log would be the only record of a gate's verdict. The agent's
Builds & Gates scan (/build_scan, the tab of the same name) turns it into a durable one:
- Configured, from stack-metadata only: which gates each application switched on, with the
attribute that did it —
enforce,report,off, or not available for a type without that gate. - Runtime, from the cluster: the build Jobs of the build namespace, their init containers, and in full mode the verdict line each gate printed.
- Findings first: a blocked build, a retry loop, a gate image that cannot be pulled, findings
that were only printed (
report) — each naming the component and the attribute to change.
A gate switched on but never run shows as not started, not as passed.
What is deliberately not here
- Production never builds. An
image_basecomponent runs a prebuilt image named by itsversion; it has a deploy directory and no build Job, so there is no gate — promotion is a change of that attribute, from an image a gated build pushed. - No external CI. The build Job is the pipeline. Branch protection, code review rules and signing live where your repository host puts them; the platform does not pretend to replace them.