diff --git a/admin_guide/pruning_resources.adoc b/admin_guide/pruning_resources.adoc index a849a9fd4b74..5a513080a39c 100644 --- a/admin_guide/pruning_resources.adoc +++ b/admin_guide/pruning_resources.adoc @@ -144,6 +144,12 @@ $ oadm prune builds --orphans --keep-complete=5 --keep-failed=1 \ --keep-younger-than=60m --confirm ---- +[NOTE] +==== +Developers can enable xref:../../dev_guide/advanced_build_operations.adoc#build-pruning[automatic build pruning] +by modifying their build configuration. +==== + [[pruning-images]] == Pruning Images diff --git a/dev_guide/builds/advanced_build_operations.adoc b/dev_guide/builds/advanced_build_operations.adoc index bcaf74c2e9b9..ed9e96553417 100644 --- a/dev_guide/builds/advanced_build_operations.adoc +++ b/dev_guide/builds/advanced_build_operations.adoc @@ -262,3 +262,37 @@ whenever the first build is run and produces a new image with the binary artifact, the second build is automatically triggered to produce a runtime image that contains that artifact. Therefore, both builds behave as a single build with two stages. + +[[build-pruning]] +== Build Pruning + +By default, builds that have completed their lifecycle are persisted indefinitely. +You can limit the number of previous builds that are retained by supplying a positive +integer value for `successfulBuildsHistoryLimit` or `failedBuildsHistoryLimit` +as shown in the below sample build configuration. + +[source,yaml] +---- +apiVersion: "v1" +kind: "BuildConfig" +metadata: + name: "sample-build" +spec: + successfulBuildsHistoryLimit: 2 <1> + failedBuildsHistoryLimit: 2 <2> +---- +<1> `successfulBuildsHistoryLimit` will retain up to 2 builds with a status of `completed` +<2> `failedBuildsHistoryLimit` will retain up to 2 builds with a status of `failed`, `cancelled`, or `error` + +Build pruning is triggered by the following actions: + + - the build configuration is updated + - a build completes its lifecycle + +Builds are sorted by their creation timestamp with the oldest builds being pruned first. + +[NOTE] +==== +Administrators can manually prune builds using the xref:../../admin_guide/pruning_resources.adoc#pruning-builds[oadm object pruning command]. +==== +