Jenkins
The long-standing, plugin-driven automation server: declarative or scripted Jenkinsfiles, a controller with distributed agents, and a plugin for everything. Still asked constantly because a large share of enterprise pipelines run on it, and maintaining or migrating one is real work.
on this pageshowhide
guide
overview
~1 minJenkins is a self-hosted automation server that runs pipelines described in a `Jenkinsfile` kept beside the code: a controller schedules the work, agents carry it out, and plugins supply nearly everything else. It stays on interview loops because a large share of enterprise delivery still runs on it, and the engineers who inherit those installations must explain why a build behaved as it did, not only how to write one. The hub follows the life of a pipeline. [Pipeline syntax](/topics/cloud-jenkins-pipeline-syntax) covers the two dialects and the Groovy runtime beneath them. [Stages and flow control](/topics/cloud-jenkins-stages-flow) is about ordering, parallel branches, manual gates, retries and how a failure reaches the build result. [Agents and distributed builds](/topics/cloud-jenkins-agents) is where the work physically runs. [Plugins and ecosystem](/topics/cloud-jenkins-plugins) and [credentials and security](/topics/cloud-jenkins-credentials-security) are the operator's side: what the controller loads, and what it is trusted with. [Shared libraries](/topics/cloud-jenkins-shared-libraries) is how an organisation stops copying the same pipeline between repositories. Junior rounds check that you can read a declarative Jenkinsfile and say where each part runs. Senior and principal rounds become debugging and ownership stories: a green build that should have been red, a token that surfaced in a log, a library change that broke every team at once, a controller nobody dares to upgrade. Start with the declarative syntax and the controller/agent split. Flow control makes sense once you know where each stage executes, and security and shared libraries build on both.
primer
### A pipeline is a program with a runtime A Jenkinsfile reads like configuration but is Groovy. **Declarative** syntax wraps it in a fixed schema Jenkins can check before the run starts; **scripted** syntax hands you the language directly. Either way the code runs under an interpreter that checkpoints its state so a build can outlive a controller restart, and, for untrusted code, inside a sandbox that vets each method call. Both explain error messages that look baffling until you know those layers exist. Interviewers expect you to default to declarative and justify each step outside it. ### The controller coordinates, agents execute The controller holds job configuration, build history, credentials and the plugin set; agents supply executors and workspaces. Keeping build code off the controller is a security rule as much as a capacity one. Agents may be long-lived machines or created per build as containers or Kubernetes pods: the ephemeral kind gives up warm caches in exchange for a clean, reproducible environment. **Labels** decide which agent receives which work. ### Workspaces belong to a node By default, nothing on disk travels between agents. A stage that runs elsewhere starts without the previous stage's output, so anything it needs is moved deliberately. Many "file not found" reports are really "different machine" reports. ### Failure is carried by exceptions A failing step throws, its stage fails, later stages are skipped and `post` handlers react. Anything that catches or downgrades that failure changes the outcome quietly, which is how a green build can hide a deploy that never happened. `retry` and `timeout` wrap blocks of steps; they do not make the work inside safe to repeat. ### Plugins are the product, and the risk Source control integration, the pipeline engine itself, credentials handling, container and Kubernetes agents all ship as plugins. They load into the controller with its privileges and release on their own schedules, dragging dependencies and core versions along. Pinning the plugin set and building the controller as an image is how teams keep that under control. ### Jenkins holds the keys Secrets live in one store and are bound into a limited block of steps, with console masking as a convenience rather than a guarantee. Edit rights on a job extend to every secret that job is able to bind, so permissions and folder layout are credential policy. ### Shared code means shared blast radius Shared libraries end copy-paste, but each pipeline inherits every change made to the library version it tracks. How a library is versioned, how much it is trusted, and who may merge into it matter as much as its code.
- Jenkinsfile
- A file, usually at the repository root, that defines a pipeline in declarative or scripted Groovy syntax, so the pipeline is versioned and reviewed with the code it builds.
- Controller
- The central Jenkins process: serves the UI and API, schedules builds, and keeps job configuration, history, credentials and plugins in JENKINS_HOME. Older documentation calls it the master.
- Agent
- A machine, container or pod connected to the controller that provides executors and a workspace for pipeline steps; either permanent or provisioned for one build.
- Executor
- A slot on a node that runs one piece of pipeline work at a time; a node's executor count caps how much it runs concurrently.
- Label
- A tag assigned to nodes. A pipeline's label expression restricts which nodes may run its work, routing builds to machines with the right tools or hardware.
- Workspace
- The directory on a node where a build checks out code and writes output. Each node has its own; nothing is shared between nodes automatically.
- Declarative pipeline
- Jenkinsfile syntax with a fixed pipeline, agent, stages and steps structure, validated before the run, with directives such as when, post, options and input.
- Scripted pipeline
- Jenkinsfile syntax built from node blocks and general Groovy control flow: more flexible than declarative, with less checking before the run.
- CPS
- Continuation-passing style: the transformation Jenkins applies to pipeline Groovy so the program's state can be saved between steps and resumed after a restart.
- Script security sandbox
- The layer that intercepts method calls made by untrusted pipeline code and permits only signatures on an approved list; administrators can approve more.
- withCredentials
- The pipeline step that binds a stored credential, by ID, to environment variables for the steps inside its block only, masking the literal value in the console log.
- Shared library
- A separate repository of reusable pipeline steps and classes, registered in Jenkins and loaded by Jenkinsfiles by name and version.
- Configuration as Code
- A plugin, often called JCasC, that defines controller configuration in YAML, so a controller can be rebuilt from files instead of settings clicked into the UI.
Follow one commit. The source host notifies the controller through a webhook, or the controller polls. The controller reads the `Jenkinsfile` from that commit, compiles it, loads any shared library it names and queues its work. Each block that needs a machine waits in the queue until a node whose labels match has a free executor; with a cloud plugin configured, a matching agent can be created on demand and discarded afterwards. Steps run on that agent, in its workspace, and stream their output back to the controller, which stores logs and results. The example below is illustrative rather than a template, but it shows most of the hub meeting in one file: ```groovy @Library('[email protected]') _ // versioned shared library pipeline { agent none // no executor held at pipeline level stages { stage('Build') { agent { label 'linux && jdk21' } steps { sh './gradlew build'; stash name: 'app', includes: 'build/libs/*.jar' } } stage('Deploy') { agent { label 'deploy' } // another node, another workspace steps { unstash 'app' withCredentials([string(credentialsId: 'deploy-token', variable: 'TOKEN')]) { sh './deploy.sh' // reads $TOKEN from the environment } } } } post { failure { notifyTeam() } } // a step defined in the library's vars/ } ``` Each line leans on a different section. The first line is shared-library versioning. `agent none` and the per-stage agents are the controller/agent model, and the `stash` exists because the two stages may land on different machines. The credential stays in the controller's store and reaches the process environment for a single block. The `post` handler reacts to the result that flow control computed. Around the file sit the parts a pipeline author rarely sees: the plugin set that makes every one of those steps exist, the authorization rules that decide who can edit the job or the library, and the controller configuration that ideally lives in version control too.
- Pipeline Syntax →
Where every Jenkinsfile starts: the declarative skeleton, how scripted differs, and the Groovy runtime behind both.
- Agents & Distributed Builds →
Where each stage actually runs: controller versus agent, labels, container and pod agents, and workspaces that stay on their node.
- Stages & Flow Control →
Parallel branches, post conditions, manual gates and retries, and how a step failure does or does not become the build result.
- Credentials & Security →
How secrets are stored, scoped and bound, where masking stops helping, and why job permissions amount to credential access.
- Shared Libraries →
Reusing pipeline code across repositories once the single-Jenkinsfile basics are solid, including versioning and trust.
- Plugins & Ecosystem →
The operator's view: what plugins are, why upgrades are coupled, and how to keep a controller's plugin set reproducible.
Running build steps on the controller's built-in node because it is convenient; that gives build code a path to JENKINS_HOME and every credential stored there.
Treating console masking as secret protection: it hides one exact string, so an encoded, escaped or archived copy of the value still leaks.
Interpolating a secret into a double-quoted Groovy string for
sh, which puts the value into the command line before masking can see it.Silencing a failing command with
returnStatus,catchErroror a bare try/catch, then shipping a deploy on top of tests that actually failed.Wrapping a deployment or migration in
retryas if it were idempotent; each attempt reruns the whole block from its start.Assuming a later stage on a different agent can see files an earlier stage wrote; move them explicitly with
stashor an artifact store.Loading a shared library implicitly from a moving branch, so one merge changes every pipeline at once with no way for a team to pin or roll back.
Handing out merge rights on a globally configured library casually; its code runs outside the sandbox, so those rights amount to controller administration.
Interviewers expect you to place Jenkins as well as operate it. Its neighbours are hosted CI systems tied to a source host, such as GitHub Actions and GitLab CI, and Kubernetes-native pipeline engines such as Tekton. The trade-off that separates them is ownership: Jenkins is self-hosted and extended through plugins, which gives full control over where builds run and what they can reach, at the price of running, patching and securing the controller yourself. Hosted systems remove that operational load but tie pipeline definitions to the platform's own format and runners. Jenkins usually sits mid-toolchain: it pulls from Git, builds and tests with the project's own tools, publishes to an artifact repository or registry, and either deploys itself or hands off to a GitOps tool such as Argo CD or Flux. Many teams keep Jenkins for build and test and move deployment to that reconciliation model. Migration is a question in its own right. A convincing answer inventories what the controller actually does — jobs, plugins, credentials, shared libraries, the agents and network access they depend on — before choosing a target, because the plugins and libraries usually hold the logic that does not port directly.
explore
- Pipeline Syntax5 questions
- Stages & Flow Control5 questions
- Agents & Distributed Builds6 questions
- Plugins & Ecosystem5 questions
- Credentials & Security5 questions
- Shared Libraries6 questions
questions
page 2 of 2A long-lived Jenkins controller has grown to roughly 200 installed plugins. How do you decide what to remove, and what does removing one actually cost?
basics
~20 sGrade each plugin by evidence of use, maintenance status and whether a scripted alternative exists. Removal is not free: job configs referencing it stop deserializing, so plan for old-data breakage — and often a curated rebuild beats pruning in place.
showing 31–32 of 32