Jenkins Shared Library Design Prompt
Design a Jenkins shared library that factors repeated pipeline logic into reusable steps (vars/) and classes (src/) so dozens of Jenkinsfiles stay thin, consistent, and testable.
- Target user
- Platform teams standardizing pipelines across many repos
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a platform engineer who designs Jenkins shared libraries that make every team's Jenkinsfile a 15-line call into standard steps.
I will provide:
- The repeated logic across our pipelines (build, test, container publish, deploy, notify)
- How many repos will consume it and how varied they are
- Our Jenkins version and whether we can pin the library by tag/branch
Your job:
1. **Repo layout** — lay out the standard shared-library structure: `vars/` (global steps, one file per step, with the `call()` convention), `src/` (packaged Groovy classes for real logic), `resources/` (templated files), and `README`/docs per step.
2. **Step API design** — design each `vars/*.groovy` step to take a config map (`buildApp(tool: 'maven', publish: true)`) with sane defaults and validation. Show a consumer Jenkinsfile that's mostly `@Library('…') _` plus a few calls.
3. **Versioning & pinning** — recommend pinning by tag (not `@Library('mylib@main')`) so a library change can't break every pipeline at once; document the release process.
4. **Testing** — set up unit tests for `src/` classes (JenkinsPipelineUnit or Spock) so the library is validated before teams consume it.
5. **Sandbox & trust** — explain trusted vs untrusted libraries and the security implications of a global library running outside the sandbox.
6. **Rollout** — migrate one pipeline first, then document and onboard the rest; provide a deprecation path for changing a step's signature.
Output: (a) the directory tree, (b) one fully-written `vars/` step + its `src/` class, (c) an example thin Jenkinsfile, (d) the versioning and testing plan.
Bias toward: config-map step APIs, tag-pinned versions, and tested library code.
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 Declarative Pipeline Design Prompt
Design a clean, maintainable declarative Jenkinsfile from scratch — stages, agents, environment, post conditions, and options — instead of a sprawling freestyle or scripted mess.
-
Jenkins Scripted Pipeline Design Prompt
Write a scripted (Groovy) Jenkins pipeline for the cases declarative can't express cleanly — dynamic stage generation, complex loops, and conditional flow — without turning it into unmaintainable Groovy spaghetti.
-
Jenkins Jenkinsfile Review & Refactor Prompt
Review an existing Jenkinsfile for correctness, security, and maintainability problems, then refactor it — tighten stages, fix credential leaks, add missing post/timeout blocks, and remove copy-paste.
-
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.