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
| Name | Description | Default | Type |
| --- | --- | --- | --- |
| name | The name of the housekeeping job. | project | string |
| needs | The jobs that this job depends on. | [] | array |
| pipeline-retention-seconds | Retention period for automatic pipeline cleanup. Defaults to 4 weeks. | 2419200 | number |
| registry-cleanup-cadence | Cadence for the GitLab container registry cleanup policy. | 7d | string |
| registry-cleanup-keep-n | Minimum number of container tags to keep. | 100 | number |
| registry-cleanup-name-regex | Container tag regex selected by the cleanup policy. | .* | string |
| registry-cleanup-name-regex-keep | Container tag regex always kept by the cleanup policy. | (?:[0-9]+\.[0-9]+\.[0-9]+\|main\|latest) | string |
| registry-cleanup-older-than | Delete container tags older than this value. | 14d | string |
| rules | Rules controlling when the housekeeping job runs. | [{"if":"$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH","when":"on_success"},{"when":"never"}] | array |
| stage | The stage where the housekeeping job runs. | .post | string |
| stale-environment-days | Stop environments last modified before this many days. GitLab requires at least 7 days. | 30 | number |
| stopped-review-app-days | Schedule deletion for stopped review app environments older than this many days. | 30 | number |
| stopped-review-app-limit | Maximum number of stopped review app environments to schedule for deletion in one run. | 100 | number |
| tags | The runners that this job depends on. | [] | array |
| token-variable | Name of the CI/CD variable containing a GitLab token allowed to manage project settings and environments. | GITLAB_TOKEN | string |