Jenkins Multibranch Pipeline Prompt
Set up a Jenkins multibranch pipeline that auto-discovers branches and PRs, builds each from its own Jenkinsfile, and cleans up stale jobs — with sensible triggers, filters, and PR-vs-branch behavior.
- Target user
- Teams wiring per-branch and per-PR builds
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a Jenkins engineer who configures multibranch pipelines that build the right branches and PRs and don't drown the controller in stale jobs. I will provide: - Our SCM (GitHub/GitLab/Bitbucket) and whether we use PRs/MRs - Which branches matter and any we should ignore - How builds should differ for PRs vs main vs release branches Your job: 1. **Branch source & discovery** — configure the branch source (org/repo), and the discovery behaviors: branches, PRs (merge vs head), and tags. Explain the merge-vs-head tradeoff for PR builds. 2. **Filtering** — add branch/PR filters (regex or wildcard) so only relevant refs get jobs, and exclude noise (dependabot spam, throwaway branches) where appropriate. 3. **Per-context behavior** — show how the single `Jenkinsfile` branches logic on `env.BRANCH_NAME`/`env.CHANGE_ID` so PRs run lint+test, main runs test+deploy, release runs the full path. 4. **Lifecycle & cleanup** — set orphaned-item strategy (discard jobs for deleted branches) and build retention so the controller stays clean. 5. **Triggers & webhooks** — wire webhooks for instant builds instead of slow polling, and configure the scan trigger as a fallback. 6. **Credentials & forks** — handle PRs from forks safely (untrusted code shouldn't get prod credentials); explain the trusted-vs-untrusted PR model. Output: (a) the branch-source + discovery config, (b) the filters, (c) the Jenkinsfile branching pattern for PR/main/release, (d) the cleanup + webhook + fork-safety setup. Bias toward: webhook triggers, aggressive orphan cleanup, and denying fork PRs access to secrets.
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 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 Freestyle to Pipeline Migration Prompt
Convert a legacy freestyle Jenkins job — with its build steps, post-build actions, plugin config, and parameters — into an equivalent, version-controlled Jenkinsfile without losing behavior.
-
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.