Skip to main content

Manage GitLab project housekeeping from the default branch. The component configures automatic pipeline cleanup, applies a default container registry cleanup policy, stops stale environments, and schedules deletion for old stopped review app environments.

The token in GITLAB_TOKEN must be allowed to update project settings and manage environments. By default, old pipelines are deleted after 4 weeks, the container registry cleanup policy is enabled with (?:[0-9]+\.[0-9]+\.[0-9]+|main|latest) kept, and stopped review app environments older than 30 days are scheduled for deletion.

Usage

include:
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/common@stable
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/housekeeping@stable

The job only runs on the default branch unless you override rules.

Inputs

NameDescriptionDefaultType
------------
nameThe name of the housekeeping job.projectstring
needsThe jobs that this job depends on.[]array
pipeline-retention-secondsRetention period for automatic pipeline cleanup. Defaults to 4 weeks.2419200number
registry-cleanup-cadenceCadence for the GitLab container registry cleanup policy.7dstring
registry-cleanup-keep-nMinimum number of container tags to keep.100number
registry-cleanup-name-regexContainer tag regex selected by the cleanup policy..*string
registry-cleanup-name-regex-keepContainer tag regex always kept by the cleanup policy.(?:[0-9]+\.[0-9]+\.[0-9]+\|main\|latest)string
registry-cleanup-older-thanDelete container tags older than this value.14dstring
rulesRules controlling when the housekeeping job runs.[{"if":"$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH","when":"on_success"},{"when":"never"}]array
stageThe stage where the housekeeping job runs..poststring
stale-environment-daysStop environments last modified before this many days. GitLab requires at least 7 days.30number
stopped-review-app-daysSchedule deletion for stopped review app environments older than this many days.30number
stopped-review-app-limitMaximum number of stopped review app environments to schedule for deletion in one run.100number
tagsThe runners that this job depends on.[]array
token-variableName of the CI/CD variable containing a GitLab token allowed to manage project settings and environments.GITLAB_TOKENstring