Chapter 06Lesson 05~155 minutes

Checkpoint Lab — Projects, Tokens, Scanners, Analysis Parameters, and First Analysis

Complete one end-to-end local analysis with a scoped token, record effective inputs and task/gate evidence, revoke the credential, and prove cleanup without erasing durable analysis state.

CheckpointEvidence packetLeast privilegeQuality GateCleanup

Learning objectives

  • Execute one complete Community Build analysis of the synthetic fixture.
  • Predict and verify source/indexing/task/policy/credential state transitions.
  • Preserve a sanitized evidence packet that can reconstruct the run.
  • Demonstrate token revocation while keeping completed analysis history.
  • State exactly what the checkpoint proves and what remains outside scope.

1. Checkpoint charter

Analyze sonar-p06-lab against local Community Build 26.9.0.129388 using Scanner CLI 8.1.0.6389, project key academy-sonarqube-p06, and a newly generated project analysis token. Follow the analysis into the exact CE task and gate, then revoke the token.

Authorized scope only: no employer/customer source, public/shared server, production database, enterprise identity, or shared CI credential.

2. Exact assumptions

Item Assumption Evidence
SonarQube Community Build 26.9.0.129388, local/private server version/system info
Scanner CLI 8.1.0.6389 sonar-scanner --version
Scanner JRE auto-provisioned/current unless deliberately disabled scanner runtime evidence
Source synthetic Python fixture Git hash + clean status
Credential new project analysis token type/project/owner/expiry/revocation metadata; never value
Database/plugins disposable prior-chapter server; no third-party plugin required record actual DB/server info or “none required”
CI/IDE/provider not used explicitly state not used
Commercial features not used Community Build path

3. Predictions before the run

  1. src/app.py is the intended indexed source.
  2. Successful upload creates fresh report-task.txt and a new ceTaskId.
  3. After CE SUCCESS, the existing project receives a new analysis and gate evaluation.
  4. Revoking the token blocks future use but leaves that analysis durable.

4. Preflight

cd sonar-p06-lab
git status --short
REVISION=$(git rev-parse HEAD)
printf 'revision=%s
' "$REVISION"
cat sonar-project.properties
sonar-scanner --version
curl --fail --silent http://127.0.0.1:9000/api/server/version

Verify the project key/name in the UI. If missing, recreate the disposable project with the exact key; do not silently alter repository identity to match an accidental project.

5. Create the checkpoint token

Generate a new project analysis token. Record only its label, type, associated project, issuer, expiry/lifetime choice, generation time, and later revocation time. Never place the raw value in the evidence packet.

6. Execute and preserve client evidence

export SONAR_HOST_URL='http://127.0.0.1:9000'
read -rsp 'Disposable project token: ' SONAR_TOKEN; echo
export SONAR_TOKEN
sonar-scanner -Dsonar.host.url="$SONAR_HOST_URL" | tee scanner-run.log
cp .scannerwork/report-task.txt report-task.checkpoint.txt
cat report-task.checkpoint.txt

Before storing/sharing logs, search for token material and environment dumps. Do not enable debug unless normal evidence is insufficient and explicit redaction controls are in place.

7. Follow the exact server task

CE_TASK_ID=$(awk -F= '$1=="ceTaskId"{print $2}' report-task.checkpoint.txt)
curl --fail --silent -H "Authorization: Bearer $SONAR_TOKEN"   "$SONAR_HOST_URL/api/ce/task?id=$CE_TASK_ID" > ce-task.json

If PENDING/IN_PROGRESS, query again after a short interval. If FAILED, stop the success checklist, preserve the terminal response, and apply Lesson 4 before rerun.

8. Verify measures/issues/gate after CE success

  1. Confirm project identity and newest analysis context.
  2. Record Issues and Measures without asserting a fixed count.
  3. Record gate name and status.
  4. Use an API response only if the current token has documented permission; otherwise use UI evidence or a separate governed read token.
curl --fail --silent -H "Authorization: Bearer $SONAR_TOKEN"   "$SONAR_HOST_URL/api/qualitygates/project_status?projectKey=academy-sonarqube-p06"   > quality-gate.json

9. Revoke and prove final credential state

  1. Revoke the checkpoint token in My Account → Security.
  2. Record the revocation timestamp.
  3. Clear SONAR_TOKEN from the process environment.
  4. Do not retrieve the raw token from logs/history merely to test it; the UI revocation record is valid evidence.
  5. Refresh the project and verify the completed analysis remains.

Desired final state: analysis durable; credential invalid.

10. Required evidence packet

manifest.txt — server/scanner/JRE assumptions, project key/name, Git revision
sonar-project.properties — sanitized project-local analysis config
scanner-run.log — sanitized first-run log
report-task.checkpoint.txt — task bridge / CE task ID
ce-task.json — terminal CE status
quality-gate.json or UI note — final policy result
token-record.txt — scope/owner/expiry/revocation metadata, never token value
limitations.md — what this run does and does not establish

11. Claims and limitations

This proves: the recorded synthetic revision and effective inputs were accepted by the chosen scanner/server path; the report was processed; the recorded project/gate result existed; and the disposable token was revoked.

It does not prove: every language/build is configured correctly, branch/PR analysis or provider decoration works, security analysis is exhaustive, CI policy is correct, or production HA/backup/upgrade operations are ready. Those need later chapter evidence.

12. Guarded cleanup

  1. Ensure token revocation and environment cleanup.
  2. Keep the disposable project if later lessons will reuse it; otherwise delete only academy-sonarqube-p06 using supported project controls after verifying the key.
  3. Remove the local synthetic repository only after preserving the sanitized evidence packet.
  4. Never delete SonarQube database/search volumes or global server state as project-level cleanup.

Knowledge check

What final state should exist after checkpoint cleanup?

Which artifact ties upload to CE processing?

Why include the Git revision?

CE is SUCCESS but gate is ERROR. What failed?

Why is deleting database volumes invalid cleanup?

What if a future API endpoint differs?

Next lesson — Next chapter

From one scanner to the scanner ecosystem

Chapter 07 expands this controlled CLI analysis into Maven, Gradle, .NET, NPM, and Python scanner integrations and compares the build metadata each scanner owns.

Official references and version notes

Version and compatibility note

Rechecked on 2026-09-07. Mandatory examples target local/private Community Build 26.9.0.129388 and standalone SonarScanner CLI 8.1.0.6389. JRE auto-provisioning is supported by current Scanner CLI and is enabled by default unless deliberately disabled; when disabled, use the current documented scanner Java requirement rather than legacy guidance. No commercial edition, branch/PR analysis, third-party plugin, IDE connected mode, CI provider, managed database, or cloud account is required.

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.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this address.