← Workflows

阅读中文版本

Artifact Retention and Cleanup Workflow

Classify artifacts by retention need, apply lifecycle rules to expire them, and clean up storage and indexes so old artifacts do not accumulate cost.

beginner~60 mincioperationscost

Objective

Keep artifact storage bounded by retaining what matters and expiring the rest on a policy.

Environment

  • An artifact repository with lifecycle support
  • A retention policy per artifact class

Steps

1. Classify artifacts: release, snapshot, and ephemeral

Classify artifacts: release, snapshot, and ephemeral.

Expected state: Retention needs are explicit per class.

2. Apply lifecycle rules with the right

Apply lifecycle rules with the right retention per class.

Expected state: Expiry is automatic, not manual.

3. Keep releases and evidence longer

Keep releases and evidence longer than build intermediates.

Expected state: Compliance and rollback needs are met.

4. Monitor storage growth and audit

Monitor storage growth and audit for orphaned artifacts.

Expected state: Cost and drift are controlled.

Decision points

Delete immediately or move to cold storage?

  • Cold storage for large artifacts
  • Delete

Cold storage for large, rarely used artifacts; delete only when retention has truly passed.

One policy for all or per class?

  • Per class
  • One global policy

Per class; a single policy either deletes needed evidence or keeps useless intermediates.

Expected outcome

Bounded artifact storage where releases and evidence are retained and intermediates expire per policy.

Verification

Confirm storage growth flattens after the rules apply and that a referenced release artifact is still present after cleanup runs.

Cleanup

Record the policy version and the cleanup run results.

Overview

Keep artifact storage bounded by retaining what matters and expiring the rest on a policy. Confirm storage growth flattens after the rules apply and that a referenced release artifact is still present after cleanup runs.

Steps

  1. Classify artifacts: release, snapshot, and ephemeral. Expected state: Retention needs are explicit per class.
  2. Apply lifecycle rules with the right retention per class. Expected state: Expiry is automatic, not manual.
  3. Keep releases and evidence longer than build intermediates. Expected state: Compliance and rollback needs are met.
  4. Monitor storage growth and audit for orphaned artifacts. Expected state: Cost and drift are controlled.
aws s3api put-bucket-lifecycle-configuration --bucket artifacts \
  --lifecycle-configuration file://rules.json
# expire snapshots after 30 days, keep releases

Verification

  • Bounded artifact storage where releases and evidence are retained and intermediates expire per policy.

Decision points

  • Delete immediately or move to cold storage? Options: Cold storage for large artifacts; Delete. Recommended: Cold storage for large, rarely used artifacts; delete only when retention has truly passed.
  • One policy for all or per class? Options: Per class; One global policy. Recommended: Per class; a single policy either deletes needed evidence or keeps useless intermediates.