Checkpoint Lab — Quality Gates, Conditions, Policies, and Pipeline Enforcement
Produce a two-run quality-gate evidence packet that proves the gate definition, assignment, pass/fail analyses, CI enforcement behavior, rollback, and policy-change governance.
Learning objectives
- Execute a reproducible two-run pass/fail gate experiment from a clean local fixture.
- Predict and verify at least two state changes before each analysis.
- Prove the exact gate definition and project assignment used by every result.
- Demonstrate asynchronous status inspection and explicit CI-style enforcement.
- Document a policy-change process with ownership, rationale, impact review, and rollback.
- Revoke lab credentials and verify cleanup without destroying retained evidence.
1. Checkpoint objective and acceptance criteria
Build an edition-aware quality-gate dossier that a reviewer can reconstruct without access to your shell history. You will prove one passing run, one failing run, the exact gate definition shared by both, the Compute Engine task behind each result, and the behavior of CI-style gate enforcement.
2. Record assumptions before touching policy
Date: 2026-09-07
SonarQube: Community Build 26.9.0.129388
Scanner: SonarScanner CLI 8.1.0.6389
Project: academy-sq-ch11
Gate: Academy Ch11 Coverage Gate
Condition: overall Coverage < 80.0% => fail
Token: project-analysis token; value never recorded
Commercial features: none required
CI/provider integration: none required; scanner wait simulates enforcement
Database/plugin/identity assumptions: inherited local lab server; no third-party plugin or IdP required
If your actual versions differ, replace these assumptions with observed values and re-check current documentation before executing the commands.
3. Preflight and guarded resources
-
Confirm
SONAR_HOST_URLresolves only to your authorized lab instance. - Confirm the project/gate names are disposable and not used by other teams.
- Confirm the gate is not the instance default.
- Confirm your analysis token is project-scoped and can be revoked after the lab.
- Confirm enough disk/memory exists for the already-running local SonarQube instance.
-
Create
evidence/outside any resource that a cleanup command will delete.
4. Write predictions before Run A and Run B
| State | Run A prediction | Run B prediction | How verified |
|---|---|---|---|
| Git revision | Pass fixture SHA | Different SHA with untested code | git rev-parse HEAD |
| Gate definition | Coverage < 80 fails | Unchanged | UI/API gate evidence |
| Coverage report | >=80% | <80% | Coverage XML + SonarQube measure |
| CE task | Unique task, expected SUCCESS | New unique task, expected SUCCESS | ceTaskId + CE API/UI |
| Gate result | OK | ERROR | Gate API/UI after matching CE completion |
| Default scanner command | Success | May still succeed after upload | Captured return status |
| Wait-enabled scanner | Success if gate OK | Fails CI-style step on gate ERROR | Captured wait-mode status/log |
5. Execute the two-run experiment
Use the exact fixture and gate workflow from Lesson 2. Do not improvise new thresholds midway. For each run:
-
Save revision SHA and
sonar-project.properties. - Generate and preserve
coverage.xml. - Run the scanner and preserve the full log.
- Copy
.scannerwork/report-task.txtimmediately. - Extract and record
ceTaskId. - Wait for the matching CE task; record status/error if any.
- Record project coverage measure and gate result with failed-condition details.
- Record the project’s gate assignment and the gate definition again, proving policy did not change between runs.
6. Prove enforcement is a separate system state
At the failing revision, collect two CI-style outcomes:
# A. Default asynchronous behavior
set +e
sonar-scanner -Dsonar.host.url="$SONAR_HOST_URL" -Dsonar.token="$SONAR_TOKEN"
DEFAULT_RC=$?
set -e
# B. Explicit scanner-side gate enforcement
set +e
sonar-scanner \
-Dsonar.host.url="$SONAR_HOST_URL" \
-Dsonar.token="$SONAR_TOKEN" \
-Dsonar.qualitygate.wait=true \
-Dsonar.qualitygate.timeout=300
WAIT_RC=$?
set -e
printf 'default_rc=%s\nwait_rc=%s\n' "$DEFAULT_RC" "$WAIT_RC" \
| tee evidence/ci-enforcement.txt
The packet must explain why these statuses can differ. If your CI/provider has a native SonarQube quality check, document that as the preferred production integration and keep this scanner-wait path as a local/free demonstration.
7. Required evidence packet
evidence/
├── assumptions.txt
├── gate-definition-before.json-or.md
├── project-gate-assignment.txt
├── pass-revision.txt
├── pass-coverage.xml
├── pass-scanner.log
├── pass-report-task.txt
├── pass-ce.json
├── pass-gate.json
├── fail-revision.txt
├── fail-coverage.xml
├── fail-scanner.log
├── fail-report-task.txt
├── fail-ce.json
├── fail-gate.json
├── ci-enforcement.txt
├── gate-definition-after.json-or.md
├── policy-change-record-template.md
└── cleanup-and-token-revocation.txt
Redact secrets. A token name/scope may be evidence; its value is not.
8. Write a policy-change record even though you are not changing production policy
Create a template that future operators can use:
Change ID:
Gate / projects affected:
Current condition(s):
Proposed condition(s):
Risk or business reason:
Why code remediation is insufficient:
Representative projects tested:
Predicted pass/fail changes:
Small-change and new-code implications:
Edition / metric availability assumptions:
Approver / owner:
Deployment date:
Verification:
Rollback trigger and procedure:
Review / expiry date:
This is the governance counterweight to “just lower the threshold.”
9. Cleanup and rollback
- Confirm all evidence is outside the SonarQube project and scanner working directory.
- Revoke the project-analysis token; record revocation time.
- If the gate was created solely for this checkpoint, unassign and delete only that exact custom gate after evidence is preserved.
-
If the project was created solely for the lab, delete only
academy-sq-ch11after evidence is preserved. - Delete the local fixture/venv only if you no longer need to reproduce the packet.
- Do not delete SonarQube volumes, database data, global scanner caches, or other projects as “cleanup.”
10. Verification checklist
- □ Both revision SHAs are present and distinct.
- □ Gate definition is identical across the pass/fail experiment.
- □ Project assignment is proven.
-
□ Both scanner logs and
report-task.txtfiles are preserved. -
□ Each gate result is correlated to the correct
ceTaskId. - □ Pass run shows coverage at/above threshold and gate OK.
- □ Fail run shows coverage below threshold and gate ERROR.
- □ Default scanner behavior is not mislabeled as gate enforcement.
- □ Wait-enabled behavior is captured.
- □ No credential value appears in the packet.
- □ Cleanup/revocation is recorded.
- □ Policy-change template contains owner, rationale, impact analysis, and rollback.
11. What Chapter 11 adds to a production operating model
After this checkpoint, a quality gate is no longer a colored badge. It is a versioned policy object connected to an explicit code population, an asynchronous analysis task, measurable conditions, a project assignment, and an enforcement mechanism.
The next chapter—New Code, Clean-as-You-Code, Baselines, and Legacy Modernization—takes the most important population in that model, “new code,” and makes its baseline and modernization consequences explicit.
Knowledge check
What must stay constant to make Run A versus Run B a valid gate experiment?
The gate definition/threshold, project assignment, scanner/server baseline, and intended analysis configuration; only the controlled source/coverage variable should change.
Why preserve gate definition both before and after?
To prove the pass/fail delta came from analysis inputs/measures rather than a policy edit.
What is the minimum evidence linking a scanner run to a gate result?
Revision/effective inputs, report-task.txt with ceTaskId, matching CE completion, and the resulting project gate status under the recorded gate assignment.
Why should a provider-native quality check be preferred when supported?
It can enforce the asynchronous result without holding the scanner process/CI executor open solely to poll for gate completion.
A threshold change has no owner or rollback plan. Is it governed?
No. Quality-gate conditions are production policy and need explicit ownership, rationale, impact review, verification, and rollback.
What chapter concept must be understood next to interpret Sonar way correctly?
The new-code definition/baseline, because Sonar way intentionally evaluates its recommended conditions on the new-code population.
Official references and version notes
- Understanding quality gates — conditions, Sonar way, new/overall code, and the small-change fudge factor.
- Managing custom quality gates — creation, condition changes, permissions, and review/update workflow.
- Changing a project quality gate and fudge factor — project assignment and small-change configuration.
- Quality standards and new code — new-code definitions and Clean-as-You-Code context.
-
Scanner-only analysis parameters
—
sonar.qualitygate.wait, timeout, andreport-task.txt. - CI integration overview — supported quality-gate enforcement patterns.
- Analysis overview — asynchronous server-side processing and quality-gate computation.
- Feature comparison — Community Build versus Server/Cloud branch and pull-request boundaries.
- Web API — authenticated API usage and Web API V2 migration guidance.
- SonarQube releases — current Community Build and Server/LTA release identities.
- SonarScanner CLI 8.1.0.6389 — scanner baseline used by the local lab.
Rechecked 2026-09-07. Mandatory executable examples target SonarQube Community Build 26.9.0.129388 and SonarScanner CLI 8.1.0.6389. Current commercial reference points are SonarQube Server 2026 Release 4.1 and 2026 Release 1.5 LTA; no commercial feature is required. Sonar way, supported gate metrics, pull-request behavior, CI integrations, Web API surfaces, and defaults can evolve, so re-check the linked primary documentation before applying these examples to another release.
Keep the academy open
Support free, practical DevOps education.
Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this
address.