50 Jenkins Interview Questions and Answers 2023
50 Jenkins Interview Questions and Answers 2023
1. What is Jenkins?
Jenkins is an open-source continuous integration tool written in Java. It automates the non-human part
of the software development process, with continuous integration and facilitating technical aspects of
continuous delivery.
Jenkins helps to automate several parts of the software development process, which includes code
deployment to different environments, code testing, building the project, and others. It’s easy to set up,
has a vast plugin ecosystem, and supports distributed builds.
Continuous Integration (CI) in Jenkins involves the continuous building and testing of code every time a
team member commits changes to version control. CI helps to detect errors as quickly as possible.
Jenkins Pipeline is a set of plugins that supports implementing and integrating continuous delivery
pipelines into Jenkins. A pipeline has an extensible automation server for creating simple or complex
delivery pipelines “as code” via the Pipeline DSL.
You can create a Jenkins pipeline by writing a Jenkinsfile, which is a text file that contains the definitions
for a Jenkins Pipeline and checks into the source control repository.
6. What is a Jenkinsfile?
Jenkinsfile is a text file that contains the definition of a Jenkins Pipeline and is checked into a project’s
source control repository. It allows you to define an entire continuous delivery pipeline.
In Jenkins, a master represents the machine or system where Jenkins runs. An agent is a computer set
up to offload build projects from the master.
A build in Jenkins is a process where source code (from a version control system) is fetched, compiled,
and packaged into a deployable format like JAR, WAR, or Docker Image.
9. What is the difference between a freestyle build job and a pipeline job in Jenkins?
A freestyle build job is a flexible and very configurable option, and it’s rather GUI based. On the other
hand, a pipeline job allows you to manage multiple complex jobs with the help of pipeline scripts in the
Jenkinsfile in your source code repository.
Source Code Management (SCM), like Git, SVN, etc., is used by Jenkins to automate the build and test
process. Jenkins contains a built-in SCM module to communicate with different repositories.
11. What is Groovy in Jenkins?
Groovy is the default scripting language used for the Jenkins DSL (Domain-Specific Language). It’s used
to write scripts for Jenkins.
A job can be scheduled in Jenkins by using the “Build periodically” field in the build triggers section of
the job configuration. Jenkins uses the syntax of UNIX cron, with some minor differences.
The different types of Jenkins jobs include Freestyle projects, Pipeline, Maven, Multi-configuration
projects (Matrix projects), and External projects.
A trigger in Jenkins decides when to run the job. It can be triggered manually or automatically, such as
when code is committed to a repository, or at a specified time or interval.
A Jenkins plugin is a tool that enhances the functionality of Jenkins. It’s a way to extend Jenkins and
integrate it with other software tools. There are hundreds of Jenkins plugins available.
Some commonly used plugins in Jenkins are Git, Maven 2 project, Amazon EC2, HTML publisher, Green
Balls, Join, Build Pipeline Plugin, etc.
A build step in Jenkins is a task that needs to be executed. For example, invoking a shell script, running a
Windows batch command, running Ant, running Maven, etc.
Jenkins CLI (Command Line Interface) is a means to interact with Jenkins from a script or from your shell.
This is convenient for automation of routine tasks, bulk updates, troubleshooting, and more.
Jenkins can be backed up by periodically backing up JENKINS_HOME directory onto a separate hard disk
or into a cloud storage system. Also, there are backup plugins available such as thinBackup.
21. How can you clone a Git repository via Jenkins?
Jenkins can clone a Git repository by using the Git plugin. In the job configuration, go to “Source Code
Management” –> “Git” then enter the Repository URL.
Parameters in Jenkins are supported “parameters” that can be given when manually building Jenkins
jobs. These parameters can be text string, a list of choices, a boolean checkbox, a password, etc.
A workspace is a directory where Jenkins builds your projects: it contains the source code of the job’s
last build, and all the outputs.
To deploy a custom build of a core plugin, you need to clone the source code of the plugin, make
changes, build it, remove the original plugin from Jenkins, and install your version.
Jenkins Artifactory is a binary repository manager for use by build tools (like Maven and Gradle), CI
Servers (like Jenkins) and repository browsers (like Artifactory).
A node in Jenkins is a machine that is part of Jenkins’ environment and is capable of executing Pipelines
or Projects. Jenkins distributes the workload of building projects on different nodes.
Jenkins supports several testing and reporting plugins. Jenkins can execute shell scripts, Windows batch
commands, Ant targets, and Maven targets for automated testing.
Firstly, install Jenkins and navigate to your Jenkins dashboard. Choose ‘new item’ on the dashboard to
create a job. Configure the job with the necessary steps and save it. Then build it by clicking ‘build now’
on the job page.
Navigate to the Manage Jenkins -> Manage Plugins -> Available section. You can search for your desired
plugin, select it and then click on Install without restart or Download now and install after restart.
To add a node in Jenkins, go to Manage Jenkins -> Manage Nodes and Clouds -> New Node. Specify the
name of the node, select Permanent Agent, and specify the necessary details.
31. How do you handle secure secrets in Jenkins?
Jenkins has a credentials plugin that stores the secrets in an encrypted form on the controller’s disk and
provides a standardized API for storing and retrieving them.
A Jenkinsfile is used to define the pipeline as code and automate the pipeline process. It allows you to
script your build pipeline consisting of one or more build jobs into a single workflow.
Scripted pipelines are based on Groovy as their Domain-specific language. Declarative pipelines were
introduced to offer a simpler and more opinionated syntax for writing Jenkins Pipeline. It has a pre-
defined structure.
To parameterize a Jenkins job, enable the “This project is parameterized” option in the job
configuration, add parameters of various data types like String, Boolean, Choice, etc., and use them in
the job steps as variables.
You can troubleshoot a Jenkins build failure by checking the console output for any errors or warnings,
investigating the logs of the specific Jenkins job, checking the system logs, or even increasing the logging
level in the Jenkins system settings.
Distributed builds in Jenkins are used to distribute the load of building projects on multiple machines. It
allows for running jobs on different environments, speeding up the build process, and saving time.
Blue Ocean is a project that rethinks the user experience of Jenkins, modelling and presenting the
process of software delivery by surfacing information that’s important to development teams with as
few clicks as possible, while still staying true to the extensibility that is core to Jenkins.
Post-build actions are operations that are performed after the build steps have been executed. This can
be sending email notifications, archiving the build artifacts, triggering other jobs, and more.
Automatic builds can be configured by setting up a build trigger in the job configuration. Jenkins can poll
SCM for changes, or scripts can use the Jenkins API to trigger builds after a check-in.
40. How can you move or copy Jenkins from one server to another?
Jenkins can be moved by copying the job directory from the old server to the new one. Alternatively,
you can also use the “Move/Copy/Promote” Jenkins plugin.
41. How can you ensure that your Jenkins job executes in a specific directory?
You can specify a custom workspace in the job configuration where your Jenkins job will be executed.
Agents are essentially Jenkins environments that are set up for distributed builds. They run on different
machines that handle the job distributed by the Master.
43. How can you temporarily turn-off Jenkins Security if the administrative users have locked
themselves out of the admin console?
If you’ve locked out of Jenkins, you can disable security by editing the Jenkins configuration file
($JENKINS_HOME/config.xml). You need to change the value of the “useSecurity” field from “true” to
“false” and then restart Jenkins.
You can speed up Jenkins by distributing the build load to different machines (agents), keeping your
system updated with the latest Jenkins version, regularly cleaning up old and unnecessary data, limiting
console output, and properly tuning JVM parameters.
A Jenkins executor is a computational resource for compiling your project. Each agent can have one or
more executors. You can think of an executor as a single “thread” of building a job.
A Jenkins agent is a machine that is configured to offload build projects from the master. It listens for
requests from the Jenkins master instance and runs jobs as directed by the master.
Docker can be integrated with Jenkins using the Docker plugin. This allows Jenkins to build and publish
images to a Docker registry and to build Docker environments.
A Matrix project is a type of Jenkins job that allows running the same job multiple times in parallel. This
is useful for testing your project against different versions of a tool/library or different environments.
Git can be integrated with Jenkins using the Git plugin. This plugin enables Jenkins to fetch the source
code from the Git repository and trigger the build whenever a change is pushed to the Git repository.
A Multibranch Pipeline project type enables you to implement different Jenkinsfiles for different
branches of the same project. It automatically creates a new Jenkins job whenever a new branch is
discovered in a SCM repository.
Q: What is DevOps?
Q: What tools have you used for automation in your previous roles?