Cleanup and retention

View as Markdown

The Artifact Cleanup action deletes artifact versions based on artifact name and version name patterns. All versions matching the configured patterns are deleted during action execution.

Individual versions can also be deleted manually on the Versions tab or using the bdy artifact version delete command. Both methods require the Manage permission level in the Artifacts module. See Versions.

Artifact Cleanup action

Each row in the action configuration contains two fields: Artifact name pattern and Version name pattern. Additional rows can be added using the + button. Both fields support the * wildcard. For example, build-* matches all version names beginning with build-.

Image loading...Artifact Cleanup action form

In YAML, the form rows are the artifacts list:

yaml
- pipeline: cleanup-builds
  name: Clean up build versions
  refs:
  - refs/heads/main
  actions:
  - action: Delete build versions
    type: ARTIFACT_CLEANUP
    artifacts:
    - artifact: my-app-build
      version: build-*

Each deleted version has its own entry in the action log:

Deleting artifact version: my-app-build:build-3

Image loading...Artifact Cleanup action log

The artifacts list can have several items, for example old builds of one artifact and test versions of another. Fields shared by all actions, such as trigger_time and retry_count, are described in the action YAML reference.

Warning
The * pattern matches all version names, including release versions. To limit deletion to temporary versions, use a dedicated version name prefix, such as build- or pr-, and a corresponding wildcard pattern. The build-* pattern does not match the latest version.

Required permissions

The Artifact Cleanup action requires the Manage level for the pipeline. Read-write is not enough, even though it allows publishing versions.

A pipeline without the Manage level fails the action with this message:

Pipeline is not allowed to manage artifact: my-app-build

Open the artifact's Permissions tab, in the Pipeline section add the cleanup pipeline with the + button and set it to Manage. Do not raise the All pipelines row to Manage if only one pipeline should delete versions.

Image loading...Cleanup pipeline with Manage access

When to run the cleanup

The Artifact Cleanup action can sit in a separate pipeline or at the end of the pipeline that publishes versions:

  • Separate pipeline on a schedule - a pipeline with only the Cleanup action that runs periodically, for example once a week. Scheduling is described in On schedule.
  • Cleanup after a release - the pipeline publishes a release version, for example 3.2.0, and at the end deletes the build-* versions used for testing.

Before the first run, check in the Versions tab which versions match the pattern.

Configure retention rules

You set retention rules in the artifact's Settings tab, in the Retention section. A rule consists of a version name pattern and one of these options:

  • Keep all versions - nothing is deleted,
  • Keep the most recent - the number of newest versions to keep,
  • Keep versions from the last - the period from which versions are kept.

Image loading...Retention rule options in artifact settings

The Settings tab is available to a user whose role has the Manage level in the Artifacts module. In the REST API, the rules are the artifact's retention_rules field (Artifacts API).

Warning
A retention rule does not delete older versions when a new one is published. In tests with the Keep the most recent option, older versions matching the pattern were still on the list more than a day later. If versions must be gone at a specific time, use the Artifact Cleanup action.

Storage and billing

Artifact storage is billed per GB-hour. Storage usage is listed as Artifact GB-hours on the Billing tab in workspace settings. For current storage rates, see Usage and GB-minutes.

See also:

Last modified on Dec 2, 2026