Skip to content

CICD-396 · Pull request preview deployment ​

Encyclopedia · Preview environments and developer experience · All snippets

Previous · CICD-395 · Next · CICD-397

1. Where it fits ​

  • Placement In a trusted preview controller after namespace provisioning.
  • Prerequisites trusted preview controller, disposable environment and scoped identities for external resources.
  • Platforms kubernetes, local-lab.
  • Parameters IMAGE, PR_NUMBER.

2. Copy the snippet ​

bash
[[ "${PR_NUMBER:?}" =~ ^[0-9]+$ ]]
helm upgrade --install web ./helm/web -n "preview-$PR_NUMBER" --atomic --timeout 3m --set-string "image.ref=${IMAGE:?}"

3. How it works ​

A validated pull request ID selects the preview namespace. Helm upgrades that release and --atomic requests rollback on chart failure or timeout.

Each preview namespace owns the candidate release and its health check.

flowchart TD
  N1["Trusted PR identity"]
  N2["Preview namespace"]
  N1 --> N2
  N3["Candidate digest"]
  N4["Helm upgrade"]
  N3 --> N4
  N2 --> N4
  N5{"Release healthy"}
  N4 --> N5
  N6["Keep preview available"]
  N5 -->|Yes| N6
  N7["Request atomic rollback"]
  N5 -->|No| N7

4. Verify the result ​

Run after authorized build and isolated namespace provisioning. Use an immutable candidate digest.

Validation syntax-validated (Bash parse). Status definitions.