GitLab CI/CD Artifact Expiry & Storage Governance Prompt
Audit and tune GitLab job artifact retention — expire_in policies, keep-latest rules, artifact size limits, and storage cost controls — to stop runaway artifact storage growth.
- Target user
- Platform engineers controlling GitLab artifact storage cost
- Difficulty
- Beginner
- Tools
- Claude, ChatGPT
The prompt
You are a CI cost engineer who has reclaimed terabytes of artifact storage without breaking deploys or losing the artifacts people actually need. I will provide: - A sample of jobs that produce artifacts and their current `artifacts:` config - Storage usage report (which projects/jobs dominate, if known) - What artifacts are consumed downstream (deploys, reports, debugging) vs just produced and forgotten - Instance/group retention defaults and any cost pressure Your job: 1. **Classify artifacts by purpose** — for each artifact, decide it is: a handoff between jobs (short TTL), a release asset (long/permanent), a report GitLab parses (`reports:`), or debug-only (very short or conditional). Build a table mapping each to a recommended `expire_in` and whether it should exist at all. 2. **Set sane `expire_in`** — give concrete values: minutes/hours for intra-pipeline handoffs, days for MR debug bundles, and explicit `keep latest artifacts` handling for the default branch. Explain how the instance "keep latest artifact" setting interacts with per-job `expire_in`. 3. **Trim what's collected** — show using precise `artifacts:paths` and `artifacts:exclude` to avoid sweeping up `node_modules`, build caches, or logs that belong in `cache:` not `artifacts:`. Clarify the artifacts-vs-cache distinction for the worst offenders. 4. **Conditional artifacts** — use `rules:`/`when: on_failure` so heavy debug artifacts upload only when a job fails, not on every green run. 5. **Size guardrails** — recommend `artifacts:` size awareness and an instance/project max-artifact-size, plus a CI check that warns when a job's artifact balloons past a threshold. 6. **Cleanup of the backlog** — give the API/`glab` commands or housekeeping settings to purge already-accumulated expired artifacts and identify the top storage consumers. 7. **Guardrail going forward** — a lint/CI check that flags new jobs declaring artifacts with no `expire_in`. Output as: (a) the artifact classification table, (b) corrected `artifacts:` blocks with `expire_in`, (c) the cache-vs-artifacts fixes, (d) a backlog-cleanup script and a no-expire-in lint check.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
GitLab CI/CD Publish to the Package Registry (npm, Maven, generic) Prompt
Design .gitlab-ci.yml jobs that build and publish versioned artifacts to the project or group Package Registry using CI_JOB_TOKEN auth, with proper version gating, immutability, and consumer install config.
-
GitLab CI/CD Cross-Pipeline needs:pipeline Artifacts Prompt
Consume artifacts and job results from a separate upstream pipeline using needs:pipeline:job and needs:project, so downstream and multi-project pipelines build on real outputs instead of rebuilding.
-
GitLab CI/CD Job Timeout Budget Tuning Prompt
Set per-job and per-runner timeout budgets so hung jobs fail fast instead of burning the project timeout, and slow jobs are caught before they block merge trains or deploys.
-
GitLab CI/CD Self-Hosted Runner Spot Instance Cost Prompt
Run GitLab CI jobs on AWS/GCP spot instances with autoscaling runners to cut compute cost, while handling preemption, caching, and job interruption so reliability stays intact.
More GitLab CI/CD prompts & error guides
Browse every GitLab CI/CD prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.