コンテンツへスキップ
LatchkeyLatchkey home

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

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がどれだけ再現可能で、診断上どれだけ価値があるかに保持期間を合わせましょう。

重要なポイント

  • retentionは、アップロードされたartifactをCIが削除するまでどれくらい保持するかを設定します。
  • runnerはエフェメラルなので、あとで欲しいものはすべてartifactとしてアップロードする必要があります。
  • artifactごとに保持期間を調整しましょう: 再生成できる出力は短く、デバッグの証拠は長めに。
  • 実行ごとの大きなartifactに長い保持期間を設定するのは、ストレージ料金が予想外に膨らむ主要因です。

よくある質問

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.

関連ガイド