Jenkins Dependency Caching Prompt
Speed up Jenkins builds by caching package-manager dependencies (Maven/Gradle, npm/yarn/pnpm, pip, Go modules) correctly — right cache keys, restore/save timing, and invalidation — especially on ephemeral agents that start empty.
- Target user
- Engineers cutting dependency-download time in CI
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a build engineer who makes CI fast by caching dependencies correctly — without ever serving a stale or poisoned cache. I will provide: - My language/build tool and lockfile (pom.xml, build.gradle, package-lock.json, go.sum, requirements/poetry.lock) - My agent model (static, Kubernetes pods, cloud VMs) and where a shared cache could live - Current build time spent downloading dependencies Your job: 1. **Pick the cache location** — for ephemeral agents, a local `.m2`/`node_modules` won't survive, so recommend the right backing store: an external cache (S3/GCS via a caching plugin), a PVC, or a repository proxy/mirror (Nexus/Artifactory) — with tradeoffs. 2. **Cache key design** — key on the lockfile hash (not branch), with a restore fallback key for partial hits, so an unchanged lockfile reuses the cache and a changed one rebuilds it. 3. **Restore/save timing** — restore before install, save after a successful install only, and scope what's cached (the dependency dir, not the whole workspace). 4. **Correctness & poisoning** — never cache across trust boundaries (fork PRs shouldn't write the shared cache), verify checksums/lockfile integrity, and prefer a read-through repository proxy for the strongest correctness. 5. **Invalidation & size** — set eviction/TTL, cap cache size, and provide a manual bust mechanism for when a cache goes bad. 6. **Measure** — show before/after download time and cache hit-rate so the caching is proven worthwhile. Output: (a) the cache-location recommendation, (b) the lockfile-based key + fallback, (c) the restore/save steps for my tool, (d) the poisoning/invalidation guardrails. Bias toward: lockfile-hashed keys, save-only-on-success, and a repository proxy or read-only cache for fork PRs.
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
-
Jenkins Artifact & Cache Strategy Prompt
Design how a Jenkins pipeline stores and reuses artifacts and caches — archiving, stash/unstash between stages, external artifact repos, and cache keys — so builds are fast and outputs are traceable.
-
Jenkins Migrate to Ephemeral Agents Prompt
Move from long-lived static Jenkins agents to ephemeral, provisioned-on-demand agents (cloud VMs or containers) — so every build starts from a clean image, capacity scales to zero, and snowflake nodes disappear.
-
Jenkins Monorepo Pipeline Prompt
Design a Jenkins pipeline for a monorepo that builds and tests only the components affected by a change — path-based change detection, per-service stages, and correct dependency ordering — instead of rebuilding everything every time.
-
Jenkins Agent & Executor Label Strategy Prompt
Design a Jenkins agent and label scheme so jobs land on the right node — build tools, OS, GPU, network zone — without pinning to a single machine, overloading executors, or leaving capacity idle.
More Jenkins prompts & error guides
Browse every Jenkins 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.