# artifact retentionとは? CIの出力を賢く保存する

> artifact retentionは、CIがbuild出力・ログ・レポートを削除するまでどれくらい保持するかを制御します。何をどれくらい残すかを学びます。

Source: https://latchkey.dev/ja/learn/ci-cd-concepts/what-is-artifact-retention  
Updated: 2026-06-25

artifact retentionとは、buildが生成するファイル - バイナリ、テストレポート、ログ - を、ストレージコストを抑えるために自動削除するまでCIがどれくらい保持するかのポリシーです。

各実行はartifactを出力できます: コンパイルされたバイナリ、coverageやテストのレポート、スクリーンショット、ログ。retentionは、それらがどれくらい残るかを決めるルールです。短すぎるとデバッグの証拠を失い、長すぎるとストレージ料金が膨れ上がります。

## artifactとは何か

artifactとは、runnerが破棄されたあとも保持されるようにjobがアップロードするあらゆるファイルです。runnerはエフェメラルなので、あとで確認したいもの - 失敗したテストのスクリーンショット、buildされたパッケージ、ログのバンドル - は明示的にartifactとしてアップロードしなければ、runnerとともに消えてしまいます。

## retentionが存在する理由

artifactは課金対象のストレージを消費し、数千回の実行にわたって積み上がります。retentionは設定された期間のあとにそれらを自動削除し、ストレージが際限なく増えないようにします。プロバイダはデフォルトの保持期間(多くは数週間から90日)を適用し、それをartifactごとに短くも長くもできます。

## ポリシーの選び方

- 再生成できる、大きく再現可能なbuild出力には短い保持期間を。
- 回帰のデバッグに必要になりうるテストレポートやログには長めの保持期間を。
- 一律の単一設定ではなく、artifactごとに個別の保持期間を。
- releaseのartifactは、CIのartifactストレージではなく本物のregistryに置くべきことが多いです。

## よくある間違い

毎回の実行で巨大なartifactをデフォルトの長い保持期間でアップロードするのが、予想外のストレージ料金のよくある原因です。逆の間違い - 短すぎる保持期間 - は、断続的な失敗のデバッグに必要だった証拠を削除してしまいます。各artifactがどれだけ再現可能で、診断上どれだけ価値があるかに保持期間を合わせましょう。

## FAQ

### What is What is artifact Retention? storing CI outputs sensibly?

Every run can emit artifacts: compiled binaries, coverage and test reports, screenshots, logs. Retention is the rule that decides how long those stick around. Set it too short and you lose debugging evidence; too long and storage bills balloon.

### What an artifact is?

An artifact is any file a job uploads to be kept after the runner is destroyed. Because runners are ephemeral, anything you want to inspect later - a failing test’s screenshot, a built package, a log bundle - must be explicitly uploaded as an artifact or it vanishes with the runner.

### Why retention exists?

Artifacts consume billed storage that accumulates across thousands of runs. Retention automatically deletes them after a set period so storage does not grow without bound. Providers apply a default window (often a few weeks to 90 days) that you can shorten or lengthen per artifact.

### Common mistakes?

Uploading huge artifacts on every run with the default long retention is the usual cause of surprise storage bills. The opposite mistake - too-short retention - deletes the evidence you needed to debug an intermittent failure. Match the window to how reproducible and how diagnostically valuable each artifact is.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
