How to Answer in an Interview
- Start with a one-sentence definition, then give a short example
- Mention why it matters (speed, safety, repeatability)
- When you have real experience, say it: *In my project we used...*
- If you do not know, explain how you would find out
Section A: CI/CD and Jenkins Basics
Q1. What is Continuous Integration?
Developers merge small changes often into a shared branch, and each change is built and tested automatically. The goal is to find problems within minutes, while the change is still fresh, instead of during a late integration phase.
Q2. What is the difference between Continuous Delivery and Continuous Deployment?
In Continuous Delivery every change that passes the pipeline is ready to release, but a human decides when to deploy. In Continuous Deployment a passing change goes to production automatically with no manual step.
Q3. What is Jenkins?
Jenkins is an open-source automation server written in Java. It runs jobs and pipelines that build, test and deploy software, triggered by code changes, schedules or other events. Its large plugin ecosystem connects it to almost every tool.
Q4. Explain the Jenkins architecture.
A controller (formerly master) stores configuration, shows the UI, schedules builds and runs the pipeline engine. Agents (nodes) execute the build steps on executors. Agents connect by SSH, an inbound connection (WebSocket/TCP) or are created on demand in Kubernetes or Docker. Best practice: zero executors on the controller.
Q5. What is an executor?
A slot on a node that runs one build at a time. A node with 4 executors can run four builds in parallel. The number depends on CPU, memory and the kind of work.
Q6. What is a Jenkins plugin?
An extension that adds features such as Git support, Docker, Kubernetes, SonarQube or Slack. Plugins are installed in Manage Jenkins → Plugins. Fewer, well-maintained plugins mean fewer security and upgrade problems.
Q7. What is JENKINS_HOME?
The directory where Jenkins stores configuration, jobs, credentials (encrypted), plugins and build history. It is the folder you back up and restore.
Q8. What is the difference between LTS and weekly releases?
Weekly releases come every week with the latest changes. LTS (Long-Term Support) is a stable line chosen about every 12 weeks, with point releases for fixes. Use LTS for production.
Q9. What Java version does Jenkins need?
It depends on the release. Current LTS lines have moved on from Java 17 and require Java 21 or newer. Always check the official Java support policy before upgrading.
Section B: Jobs and Pipelines
Q1. What is a Freestyle job?
A job configured through the UI with a list of build steps, triggers and post-build actions. It is simple to start but hard to review, version and reuse. Prefer pipelines for real projects.
Q2. What is a Jenkins Pipeline?
A pipeline as code: the build, test and deploy process written in a Jenkinsfile and stored in Git. It is versioned, reviewed, and can express complex flows with stages, parallel steps, conditions and approvals.
Q3. What is a Jenkinsfile?
A text file, usually at the repository root, that defines the pipeline. Jenkins reads it from source control, so the pipeline changes together with the code.
Q4. Declarative vs Scripted pipeline: what is the difference?
Declarative has a fixed, readable structure (pipeline { agent, stages, post }) with built-in validation, and is recommended. Scripted is plain Groovy inside node { }: more flexible but easier to make mistakes. You can use a script { } block inside declarative for rare cases.
Q5. What are stages and steps?
A stage is a named phase such as Build or Test, shown in the stage view. A step is a single action inside a stage such as sh 'make' or echo.
Q6. Write a minimal declarative pipeline.
Use the structure: pipeline { agent any; stages { stage('Build') { steps { sh 'make' } } } }. Add post { always { ... } } for cleanup and notifications.
Q7. What does the post section do?
It runs after the stages with conditions such as always, success, failure, unstable, changed and fixed. Use it for test reports, cleanup and notifications.
Q8. How do you define environment variables?
In an environment { } block at pipeline or stage level. Credentials can be bound with credentials('id') there, or with withCredentials inside steps.
Q9. How do you make a pipeline parameterized?
Add parameters { string(...); choice(...); booleanParam(...) } and read them with params.NAME. The job then shows Build with Parameters.
Q10. How do you run stages in parallel?
Use parallel { stage('A') { ... } stage('B') { ... } } inside a stage. Each branch can have its own agent. Add failFast true to stop others when one fails.
Q11. What does the when directive do?
It runs a stage only if a condition is true, for example when { branch 'main' }, when { expression { params.DEPLOY } }, changeset, tag or environment.
Q12. What is a Multibranch Pipeline?
A job that scans a repository and creates a pipeline job for each branch and pull request that contains a Jenkinsfile. Branches are added and removed automatically.
Q13. What is the input step?
It pauses the pipeline and asks a person to approve or provide values. Put it in a stage with agent none and add a timeout so it does not wait forever or hold an executor.
Section C: Triggers, Credentials, Tools
Q1. How can a build be triggered?
By a webhook from the Git host (best), Poll SCM, a cron schedule, upstream job completion, a remote API call with a token, or manually.
Q2. Poll SCM vs webhook: which is better?
A webhook pushes an event instantly and costs almost nothing. Poll SCM makes Jenkins ask Git on a schedule, which wastes resources and delays builds. Use polling only when webhooks cannot reach Jenkins.
Q3. Explain the H in cron expressions.
H means a hash-based value that spreads jobs across the time range so they do not all start at the same minute. H/15 * * * * runs every 15 minutes at a spread offset.
Q4. How does Jenkins store secrets?
In the credentials store, encrypted with keys in JENKINS_HOME/secrets. Types include secret text, username and password, SSH key, certificate and secret file. In pipelines use withCredentials or credentials('id') so values are masked in logs.
Q5. How do you avoid leaking a password in a pipeline?
Bind it with withCredentials, use single quotes for sh so the shell reads the variable, avoid echo and set -x, and prefer --password-stdin for tools like docker login.
Q6. How do you manage tool versions such as JDK and Maven?
Configure them in Manage Jenkins → Tools, then use tools { maven 'maven-3.9' } in the pipeline; or better, use Docker agents so the toolchain version lives in the image.
Q7. How do you install and update plugins safely?
Use the Plugin Manager, read release notes, test in staging first, update in small batches, and keep a pinned plugins.txt for reproducible images.
Section D: Agents and Workspaces
Q1. How do you add an agent?
Create a node under Manage Jenkins → Nodes, set its labels and remote directory, choose a launch method (SSH, inbound agent over WebSocket, or a cloud plugin such as Kubernetes) and confirm it connects. Use credentials and host key verification for SSH.
Q2. What are labels?
Tags on agents (for example linux, docker, gpu) that pipelines use with agent { label 'docker' } to choose where a job runs.
Q3. Why not build on the controller?
A build could read or change JENKINS_HOME, steal credentials or overload the controller. Set controller executors to 0 and run builds on agents.
Q4. What is a workspace and how do you clean it?
The directory on the agent where the job checks out and builds code. Clean it with cleanWs() (Workspace Cleanup plugin) in post, or use ephemeral agents so every build starts empty.
Q5. What are ephemeral agents?
Agents created for one build and destroyed afterwards (Docker containers, Kubernetes pods, cloud VMs). They give clean, identical environments and scale automatically.
Q6. What is the difference between stash and archiveArtifacts?
stash/unstash pass files between stages or agents inside one build (temporary). archiveArtifacts stores files with the build for download later (kept according to retention).
Quick Scenario Questions
| Scenario | Good answer |
|---|---|
| Build works locally but fails in Jenkins | Compare tool versions, environment variables, user and permissions, and missing files. Reproduce in the same Docker image. |
| Builds are queued for a long time | Check executors, agent labels and availability. Add agents, reduce build time, enable autoscaling. |
| A password appears in the log | Rotate it immediately, find the cause (interpolation, debug print), fix and add a scan. |
| Two builds deploy to the same environment at once | Use lock and disableConcurrentBuilds. |
| Developers want a standard pipeline for 50 repositories | Create a shared library with a template step and version it with tags. |
Practice
- Answer each question out loud in 30 to 60 seconds
- Write a Jenkinsfile with parameters, parallel stages and a post section from memory
- Explain the controller and agent design on a whiteboard
- Prepare one real example of fixing a broken pipeline
Conclusion
Be ready to explain CI versus CD, controller and agents, freestyle versus pipeline, declarative syntax, triggers, credentials, labels, ephemeral agents and workspaces, each in a short definition with an example from real practice.

