Join our community Discord , if you need some help.

Cleaning up preview apps

If you deploy preview apps with dynamic names, like with the branch name in the app name, you can use Gimlet's cleanup policies to clean them up once you don't need them anymore.


This feature works only if you enabled the Github integration in GimletD.

Cleanup policy

# .gimlet/preview.yaml
app: myapp-{{ .GITHUB_BRANCH | sanitizeDNSName }}
env: staging
namespace: staging
name: onechart
version: 0.28.0
branch: feature/*
event: push
+ branch: feature/*
+ event: branchDeleted
+ app: myapp-{{ .BRANCH | sanitizeDNSName }}
replicas: 1
tag: "{{ .GITHUB_SHA }}"
gitRepository: laszlocph/gimletd-test-repo
gitSha: "{{ .GITHUB_SHA }}"

The above snippet has a cleanup section that is triggered

  • on the branchDeleted event,
  • if the branch that is deleted matches the feature/* pattern.

Once the policy triggers, it deletes applications that are matching the myapp-{{ .BRANCH | sanitizeDNSName }} pattern.

All three fields are mandatory.

Please note that only the {{ .BRANCH }} variable is available for the branchDeleted event.

At the time of deletion the shipped artifacts and their extensive variable set is not available, only the branch name is known that got deleted. Hence the {{ .GITHUB_BRANCH }} usage throughout the manifest, except in the cleanup policy.