Skip to content

Commit 40be783

Browse files
authored
Merge pull request #9506 from circleci/EXEC-5563-add-job-level-cache-retention
[EXEC-5563] Add job retention documentation with config.yml example
2 parents d7fc85d + bee2cad commit 40be783

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

docs/guides/modules/optimize/pages/persist-data.adoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,26 @@ When you have determined your preferred storage retention for each object type,
139139

140140
The *Reset to Default Values* button will reset the object types to their default storage retention periods: 30 days for artifacts, and 15 days for caches and workspaces.
141141

142+
You can also configure job retention periods to control how long job data is kept. Job retention specifically controls cache retention at the job level. This setting can be configured from 1 day to 15 days using string values (for example, "1d", "7d", "15d") in your CircleCI configuration YAML file. Job retention reduces the organization-level retention from the default by automatically removing cache data after the specified period.
143+
144+
The following example shows how to configure job retention in your configuration file:
145+
146+
[source,yaml]
147+
----
148+
version: 2.1
149+
150+
jobs:
151+
test:
152+
docker:
153+
- image: cimg/node:18.0
154+
retention:
155+
caches: 7d
156+
steps:
157+
- checkout
158+
- run: npm install
159+
- run: npm test
160+
----
161+
142162
Anyone in the organization can view the custom usage controls, but you must be an admin to make changes to the storage periods.
143163

144164
image::guides:ROOT:storage-usage-controls.png[storage-usage-controls]

docs/reference/modules/ROOT/pages/configuration-reference.adoc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@ Each job consists of the job's name as a key and a map as a value. A name should
380380
| N
381381
| String
382382
| Amount of CPU and RAM allocated to each container in a job.
383+
384+
| `retention`
385+
| N
386+
| Map
387+
| Configure job retention periods for cache data (1-15 days, for example, "1d", "7d", "15d"). Reduces organization-level retention by automatically removing cache data after the specified period.
383388
|===
384389

385390
^(1)^ One executor type should be specified per job. If more than one is set you will receive an error.
@@ -484,6 +489,33 @@ jobs:
484489

485490
'''
486491

492+
[#retention]
493+
==== `retention`
494+
495+
Configure job retention periods to control how long job data is kept. Job retention specifically controls cache retention at the job level. This setting can be configured from 1 day to 15 days using string values (for example, "1d", "7d", "15d"). Job retention reduces the organization-level retention from the default by automatically removing cache data after the specified period.
496+
497+
For more information on cache retention, see the xref:guides:optimize:persist-data.adoc#custom-storage-usage[Persisting data overview] page.
498+
499+
*Example:*
500+
501+
[source,yaml]
502+
----
503+
version: 2.1
504+
505+
jobs:
506+
test:
507+
docker:
508+
- image: cimg/node:18.0
509+
retention:
510+
caches: 7d
511+
steps:
512+
- checkout
513+
- run: npm install
514+
- run: npm test
515+
----
516+
517+
'''
518+
487519
[#parallelism]
488520
==== `parallelism`
489521

0 commit comments

Comments
 (0)