0% found this document useful (0 votes)
62 views32 pages

Jenkins Interview Ques

The document discusses Jenkins, an open-source automation server for continuous integration and continuous delivery. It provides definitions for CI, CD, and continuous deployment. It also lists common uses of Jenkins and ways to install, configure, trigger, and programmatically control Jenkins jobs.

Uploaded by

k.saimanikanta24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views32 pages

Jenkins Interview Ques

The document discusses Jenkins, an open-source automation server for continuous integration and continuous delivery. It provides definitions for CI, CD, and continuous deployment. It also lists common uses of Jenkins and ways to install, configure, trigger, and programmatically control Jenkins jobs.

Uploaded by

k.saimanikanta24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Jenkins Interview Questions For Freshers

1. What is Jenkins?

Jenkins is a self-contained, open-source automation server that can be


used to automate all sorts of tasks related to building, testing, and
delivering or deploying software. Jenkins can be installed through
native system packages, Docker, or even run standalone by any machine
with a Java Runtime Environment (JRE) installed.

2. Tell me something about Continuous Integration, Continuous


Delivery, and Continuous Deployment?

Continuous Integration: A software development process where the


changes made to software are integrated into the main code as and when
a patch is ready so that the software will be always ready to be - built,
tested, deployed, monitored - continuously.

Continuous Delivery: This is a Software Development Process where


the continuously integrated (CI) changes will be tested & deployed
continuously into a specific environment, generally through a manual
release process, after all the quality checks are successful

Continuous Deployment: A Software Development practice where the


continuously integrated (CI) changes are deployed automatically into
the target environment after all the quality checks are successful

Based on the level of automation, the above three paradigms can be


better represented as below -
CI/CD and Continuous Deployment

3. What are the common use cases Jenkins is used for?

Jenkins being open-source automation can be used for any kind of


software-based automation. Some of the common use-cases include but
not limited to -

 Software build jobs


 Sanity/Smoke/CI/Regression test jobs
 Web/Data Scraping related jobs
 Code coverage measurement jobs
 General-purpose automation
 Reverse Engineering jobs
 Key Decoding jobs & many other jobs where software automation will
be applicable.
You can download a PDF version of Jenkins Interview Questions.
Download PDF
4. What are the ways to install Jenkins?

Jenkins can be installed using -


1. Native System Package Manager like - apt (Linux), brew (Mac), etc.
2. Docker (popular docker images for Jenkins is available for different
platforms like Unix/Mac/Windows in the docker registry)
3. Kubernetes (available as a helm chart and can be installed on our
Kubernetes clusters)
4. Standalone (on any machine with a Java Runtime Environment
installed)

For more detailed installation instructions refer official documentation

5. What is a Jenkins job?


A Job/Project is the fundamental unit of a logical work (like a software
build, an automation task, test execution, etc) using the Jenkins
automation server and other required plugins, configurations &
infrastructures.

Jobs can be of different types like - a freestyle project, a multi-


configuration project, a pipeline project, a multi-branch project, etc.

6. What is a Jenkins Pipeline?


Jenkins Pipeline

The pipeline is a special type of Jenkins job - simply a sequence of steps


controlled by a defined logic - which Orchestrates long-running
activities that can span across multiple build agents. It is suitable for
building pipelines (formerly known as workflows) and/or organizing
complex activities that cannot be easily achieved using a freestyle job.

Understand how to create your first pipeline here

7. What are the types of Jenkins pipelines?

Jenkins Pipelines can be either - a Declarative pipeline or a Scripted


Pipeline. Declarative pipeline makes use of numerous, generic,
predefined build steps/stages (i.e. code snippets) to build our job
according to our build/automation needs whereas, with Scripted
pipelines, the steps/stages can be custom-defined & used using a groovy
syntax which provides better control & fine-tuned execution levels.

8. Explain Jenkins Multibranch Pipeline?


Jenkins Multibranch Pipeline

It is a pipeline job that can be configured to Create a set of Pipeline


projects according to the detected branches in one SCM repository. This
can be used to configure pipelines for all branches of a single repository
e.g. if we maintain different branches (i.e. production code branches)
for different configurations like locales, currencies, countries, etc.

9. How do you store credentials in Jenkins securely?

Credentials can be stored securely in Jenkins using the Credentials


plugin, which stores different types of credentials like - Username with
a password, SSH username with the private key, AWS Credentials,
Jenkins Build Token, Secret File/Text, X509 & other certificates, Vault
related credentials securely with proper encryption & decryption as and
when required.

10. How can we stop a scheduled job from being executed


temporarily?
Disable the job from the job details page to temporarily stop all
scheduled executions & other factors/events from triggering the job and
enable it back to resume the job schedules/triggers. If a job is not
required permanently, we can delete the job from the jobs list view
page.

Intermediate Questions

11. What are the ways to trigger a Jenkins Job/Pipeline?


There are many ways we can trigger a job in Jenkins. Some of the
common ways are as below -

 Trigger an API (POST) request to the target job URL with the required
data.
 Trigger it manually from the Jenkins web application.
 Trigger it using Jenkins CLI from the master/slave nodes.
 Time-based Scheduled Triggers like a cron job.
 Event-based Triggers like SCM Actions (Git Commit, Pull Requests),
WebHooks, etc.
 Upstream/Downstream triggers by other Jenkins jobs.

12. What is Jenkins Build Cause?

Build Cause is a text attribute that represents what made a job's build to
be triggered, say it could be a Jenkins User (from UI), Timer for
Scheduled jobs, Upstream jobs for a job which was triggered by
upstream job, etc. This is mainly used to identify the nature of the
builds - be it nightly, manual, automated, etc.

13. How Jenkins knows when to execute a Scheduled job/pipeline


and how it is triggered?
Jenkins master will have the cron entries set up for the jobs as per the
scheduled Job's configurations. As and when the time for a particular
job comes, it commands agents (based on the configuration of the job)
to execute the job with required configurations.
14. What are the credential types supported by Jenkins?

In Jenkins, credentials are a set of information used for authentication


with internal/external services to accomplish an action. Jenkins
credentials are provisioned & managed by a built-in plugin called -
Credentials Binding - plugin. Jenkins can handle different credentials as
follows -

 Secret text - A token such as an API token, JSON token, etc.


 Username and password - Basic Authentication can be stored as a
credential as well.
 Secret file - A secret file used to authenticate some secure data services
& security handshakes.
 SSH Username with a private key - An SSH public/private key pair for
Machine to Machine authentication.
 Certificate - a PKCS#12 certificate file and an optional password.
 Docker Host Certificate Authentication credentials.

And as we can guess, this can be extended to several other extensible


credential types like - AWS credential, Azure secrets, etc. using
commonly available plugins.

15. What are the Scopes of Jenkins Credentials?

Jenkins credentials can be of one of the two scopes - Global & System

Global - the credential will be usable across all the jobs configured in
the Jenkins instance (i.e. for all jobs). This is more suited for user Jobs
(i.e. for the freestyle, pipeline, or other jobs) to authenticate itself with
target services/infrastructures to accomplish the purpose of the job)

System - This is a special scope that will allow the Jenkins itself (i.e.
the core Jenkins functionalities & some installed plugins) to
authenticate itself to external services/infrastructures to perform some
defined tasks. E.g. sending emails, etc.

16. What is a Jenkins Shared Library and how it is useful?


As an organization starts using more and more pipeline jobs, there is a
chance for more and more code being duplicated in every pipeline job,
since a part of the build/automation processes will be the same for most
of the jobs. In such a situation, every other new upcoming job should
also duplicate the same piece of code. To avoid duplications, the
Jenkins project brought in the concept of Shared Libraries, to code -
DRY - Don't Repeat Yourself.

Shared libraries are a set of code that can be common for more than one
pipeline job and can be maintained separately. Such libraries improve
the maintenance, modularity & readability of the pipeline code. And it
also speeds up the automation for new jobs.

17. How Jenkins jobs can be Triggered/Stopped/Controlled


programmatically?

Jenkins Remote Access API can be used to do things like -

 Retrieving information about jobs, views, nodes, builds, etc. from


Jenkins for programmatic consumption.
 Trigger a build (both parameterized & non-parameterized), stop/abort a
build, enable/disable a Job, group/remove jobs into/from views, etc.
 Create/copy/modify/delete jobs.

and many other programming language-specific functionalities. It has


wrappers for main programming languages like - Python, Ruby & Java.
It can be triggered via CURL as below -

Jobs without parameters


Simply an HTTP POST on JENKINS_URL/job/JOBNAME/build.

Jobs with parameters


Simple example - sending "String Parameters":
curl JENKINS_URL/job/JOB_NAME/buildWithParameters --user
USER:TOKEN --data id=123 --data verbosity=high

18. How to get the Jenkins version programmatically in


Jobs/Pipelines or nodes other than master?
To check the version of Jenkins, load the top-level page or any top-level
Remote Access API path like the '.../api/*' page and then check for the
'X-Jenkins' response header.
This contains the version number of Jenkins, like "1.404". This is also a
good way to check if an URL is a Jenkins URL.

19. What happens when a Jenkins agent is offline and what is the
best practice in that situation?
When a job is tied to a specific agent on a specific node, the job can
only be run on that agent and no other agents can fulfill the job request.
If the target node is offline or all the agents on that particular node are
busy building other jobs, then the triggered job has to wait until the
node comes online or an agent from that node becomes available to
execute the triggered build request.

As a result, a triggered job may sometimes wait indefinitely without


knowing that the target node is offline. So, it is always the best practice
to tie the jobs to a group of nodes & agents, referred to with a 'Label'.
Once a job is tied to a Label, instead of a specific node/agent, any of the
nodes/agents falling under the label can fulfill a build request, when a
job is triggered. This way we can reduce the overall turn-around time of
the builds.

Even then if a job is waiting for more time for the nodes/agents, then it
is time to consider adding more nodes/agents.

20. What is the Blue Ocean?


Blue Ocean is the redefined user experience for Jenkins. Designed from
the ground up for Jenkins Pipeline, it is still compatible with freestyle
jobs, Blue Ocean reduces clutter and increases clarity. Blue Ocean’s
main features include -

 Sophisticated visualizations of continuous delivery (CD) Pipelines,


allowing for fast and intuitive comprehension of your Pipeline’s status.
 Pipeline editor - makes the creation of Pipelines approachable by
guiding the user through an intuitive and visual process to create a
Pipeline.
 Personalization to suit the role-based needs of each member of the team.
 Pinpoint precision when intervention is needed and/or issues arise. Blue
Ocean shows where in the pipeline attention is needed, facilitating
exception handling and increasing productivity.
 Native integration for branch and pull requests, enables maximum
developer productivity when collaborating on code with others in
GitHub, Bitbucket, etc.

Conventional UI - Job Details Page


Conventional UI Jenkins

21. What is the Jenkins User Content service?


Jenkins has a mechanism known as "User Content", where
administrators can place files inside
the $JENKINS_HOME/userContent folder and these files are served
from yourhost/jenkins/userContent.

This can be thought of as a mini HTTP server to serve images,


stylesheets, and other static resources that you can use from various
description fields inside Jenkins.

Advanced Interview Questions

22. How is continuous integration achieved using Jenkins?


Continuous integration is a process where a developer’s code changes
are constantly integrated into the main code and the same will be tested
automatically and the results of the tests will decide whether the change
is ready for deployment. In this process -

 Developer Makes a change - commit/pull_request - in feature/dev


branch
 Source Control Management system generates appropriate events
 SCM Specific Jenkins Plugins like Git/SVN will detect those events
from the configured repositories and these events will be used to
Trigger - build/dependent/test - jobs on Jenkins
 After the Test/Dependent jobs are completed, the change/patch will be
labeled according to the status of the test job
 Based on the Status (i.e. readiness of a change to be merged with the
main branch), the Continuous Delivery or Continuous Deployment
strategy/tool will take it forward.

23. What is Artifact Archival & how to do it in Pipelines?


Artifacts are the exportable/storable/archivable results of a specific job
build. This can be configured using a plugin called - Copy artifact
Plugin. Based on the configured pattern, the files/directories matching
the configured patterns will be archived for a Jenkins build, which can
be used for future references. In the pipeline, it can be configured as
follows -
archiveArtifacts artifacts: 'output/**/*'

24. How to configure inclusions & exclusions in Artifacts Archival?

Artifact archival takes in a pattern for matching target files. Similarly, it


also takes in a pattern (ANT build system pattern for matching files) for
exclusion as well which will be ignored while selecting the files for
archival.

For e.g.
archiveArtifacts artifacts: 'output/*.txt', excludes:
'output/specific_file.txt'

The above command will archive all the text files from the output folder
except specific_file.txt

25. How can we share information between different build steps or


stages in a Jenkins Job?
Every build step or stage will be running in its process and hence
sharing information between two different build steps is not so direct.
We can use either a File, a Database Entry, an Environment Variable,
etc. to share info from one build step to another or a post-build action.

26. How code coverage is measured/tracked using Jenkins in a CI


environment?

Using language-specific code coverage plugins like JaCoCo, CodeCov,


etc or generic tools/plugins like Sonarqube which will add the code
coverage data to builds with some minor tweaks in the code and the
same can be displayed as a graph in Jenkins.

27. Default Environment Variables by Jenkins & How to introduce


custom environment variables?
Jenkins provides several environment variables by default like -
BRANCH_NAME, BUILD_NUMBER, BUILD_TAG,
WORKSPACE, etc.

28. How can a job configuration be reset to an earlier version/state?


From the Job details page, we can use Job Config History to - See diff,
Review & Revert the Job configs from the history of changes we have
made to a particular job. This will be super useful when a job is
misconfigured by someone by mistake, it can be reviewed and reverted
easily to any of its earlier states.

29. How to do Global Tools Configuration in Jenkins?


Global Tools are tools that need to be installed outside the Jenkins
environment and need to be controlled from within the Jenkins
environment. Hence it needs its corresponding Jenkins plugin as well.
Steps to using a Global Tool generally include -

 Install the tool Plugin into the Jenkins instance, to include the global
tool into a list of global tools used by Jenkins.
 Install the tool in the Jenkins instance or provide away (maybe a
command to download and) install the tool during runtime.
 Go to Manage Jenkins -> Global Tools Configuration and Scroll
through the tool list and configure the global tool-specific
configurations.
 Make use of the installed global Tool in your job/pipeline.

30. How to create & use a Shared Library in Jenkins?


Basic requirements for a Jenkins shared library to be used in a Pipeline
Code are -

 A Repository with pipeline shared library code in SCM.


 An appropriate SCM Plugin configuration for the Jenkins instance.
 Global Shared Library should be configured in Jenkins Global
configuration.
 Include the Shared Library in the Pipeline Code and use the methods
defined in the Jenkins Shared Library.

E.g.
#!/urs/bin/env groovy
@Library('[email protected]')_

31. How to install a Custom Jenkins Plugin or a Version of Plugin


Not available in Jenkins Update Center?
Generally, it is the best practice to use the latest version of a plugin. But
there are ways to install custom plugins or outdated versions of a
published plugin. Jenkins Plugins are exported using a .hpi file and the
same can be installed in multiple ways -

Using the Jenkins CLI

java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin SOURCE


... [-deploy] [-name VAL] [-restart]
The above command Installs a plugin either from a file, an URL or from
the update center.

 SOURCE: If this points to a local file, that file will be installed. If this
is an URL, Jenkins downloads the URL and installs that as a plugin.
Otherwise, the name is assumed to be the short name of the plugin in
the existing update center (like "findbugs") and the plugin will be
installed from the update center.
 -deploy: Deploy plugins right away without postponing them until the
reboot.
 -name VAL: If specified, the plugin will be installed as this short name
(whereas normally the name is inferred from the source name
automatically).
 -restart: Restart Jenkins upon successful installation.

Advanced Installation - via - Web UI


Assuming a .hpi file has been downloaded, a logged-in Jenkins
administrator may upload the file from within the web UI:

 Navigate to the Manage Jenkins > Manage Plugins page in the web UI.
 Click on the Advanced tab.
 Choose the .hpi file under the Upload Plugin section.
 Upload the plugin file.
 Restart the Jenkins instance

Advanced Installation - via - On the master


Assuming a .hpi file has been explicitly downloaded by a systems
administrator, the administrator can manually place the .hpi file in a
specific location on the file system.

Copy the downloaded .hpi file into the JENKINS_HOME/plugins


directory on the Jenkins controller (for example, on Debian systems
JENKINS_HOME is generally /var/lib/jenkins).

The master will need to be restarted before the plugin is loaded and
made available in the Jenkins environment.

32. How to download the Console log for a particular Jenkins build
programmatically?

Using the Jenkins CLI - console - command

java -jar jenkins-cli.jar console JOB [BUILD] [-f] [-n N]

Produces the console output of a specific build to stdout, as if you are


doing 'cat build.log'

 JOB: Name of the job


 BUILD: Build number or permalink to point to the build. Defaults to the
last build
 -f: If the build is in progress, append console output as it comes, like tail
-f
 -n N: Display the last N lines.

E.g.

ssh -l <ssh_username> -p <port_no> <Jenkins_URL> console


<JOB_NAME>

33. What is Jenkins Remote Access API?


Jenkins provides remote access API to most of its functionalities
(though some functionalities are programming language-dependent).
Currently, it comes in three flavors -

 XML
 JSON with JSONP support
 Python

Remote access API is offered in a REST-like style. That is, there is no


single entry point for all features, and instead, they are available under
the ".../api/" URL where the "..." portion is the data that it acts on.
For example, if your Jenkins installation sits at interviewbit.com,
visiting /api/ will show just the top-level API features available –
primarily a listing of the configured jobs for this Jenkins instance.

Or if we want to access information about a particular build, e.g.


https://ci.jenkins.io/job/Infra/job/jenkins.io/job/master/lastSuccessfulBu
ild/, then go to
https://ci.jenkins.io/job/Infra/job/jenkins.io/job/master/lastSuccessfulBu
ild/api/ and you’ll see the list of functionalities for that build.

34. What is In-process Script Approval and how it works?


Jenkins, and several plugins, allow users to execute Groovy scripts in
Jenkins. To protect Jenkins from the execution of malicious scripts,
these plugins execute user-provided scripts in a Groovy Sandbox that
limits what internal APIs are accessible.
This protection is provided by the Script Security plugin. As soon as an
unsafe method is used in any of the scripts, the "In-process Script
Approval" action should appear in "Manage Jenkins" to allow
Administrators to make a decision about which unsafe methods, if any,
should be allowed in the Jenkins environment.
This in-process script approval inherently improves the security of the
overall Jenkins ecosystem.

35. Can we monitor Jenkins using common Observability tools?


Common monitoring platforms like DataDog, Prometheus,
JavaMelody & few others - have their corresponding Jenkins plugin,
which when configured, sends Metrics to the corresponding Monitoring
platform, which can then be Observed with the latest tools &
technologies. The same can be configured with Alarms & Notifications
for immediate attention when something goes wrong.

36. What is a Ping Thread in Jenkins and how it works?


Jenkins installs "ping thread" on every remote connection, such as
Controller/Agent connections, regardless of its transport mechanism
(such as SSH, JNLP, etc.). The lower level of the Jenkins Remoting
Protocol is a message-oriented protocol, and a ping thread periodically
sends a ping message that the receiving end will reply to. The ping
thread measures the time it takes for the reply to arrive, and if it’s taking
excessive time (currently 4 minutes and configurable), then it assumes
that the connection was lost and initiates the formal close down.

This is to avoid an infinite hang, as some of the failure modes in the


network cannot be detected otherwise. The timeout is also set to a long
enough value so that a temporary surge in the load or a long garbage
collection pause will not trip off the close-down.

Ping thread is installed on both controller & agent; each side pings the
other and tries to detect the problem from their sides.
The ping thread time out is reported through java.util.logging. Besides,
the controller will also report this exception in the agent launch log.
Note that some agent launchers, most notably SSH agents, writes all
stdout/stderr outputs from the agent JVM into this same log file, so you
need to be careful.

Conclusion
Though these are not the complete possibilities of Jenkins, we tried to
cover some of the commonly asked interview questions on core Jenkins.
We also need to understand that the Jenkins Update Center is enriched
with thousands of useful plugins that enhance the supported
functionalities of Jenkins.

Before appearing for an interview, make sure to install a Jenkins Server


on any of the supported platforms - either locally or on the cloud, install
the most common plugins (suggested by Jenkins itself & other
commonly used plugins). Try creating & building a normal freestyle
project with Git or any other SCM integration plugin and try to execute
some code from the connected Git Repository.
Also, try creating a pipeline project with JenkinsFile and a global shared
Jenkins library and build the job successfully. This will help us learn
how Jenkins actually works with some hands-on issues.

Intellipaat.

1. What is Jenkins?
Jenkins can be thought of as a free and open-source automation tool
that is used for continuous integration. It automates some of the
software development processes, such as building, testing, and
deployment. It can also be integrated with a large number of testing
and deployment technologies.
2. What is Jenkins used for?
Jenkins is used in the automation of some of the software
development processes. With Jenkins, one can continuously test
software projects so that developers can integrate the changes to
them. Jenkins facilitates continuous integration and delivery through
its built-in plugins.

3. Which architecture is recommended for a scalable


Jenkins environment?
Distributed builds architecture is prescribed for a scalable Jenkins
environment because the agents perform the main work and the
master maintains the coordination. In this way, the focus is on both the
master and the agent. In addition, the master provides the GUI and
API endpoints.

4. How to add a user in Jenkins?

1. Go to Manage Jenkins
2. Click on Create User
3. Enter all the details
4. Select Create User

5. What is Jenkins Pipeline?


Jenkins Pipeline, sometimes simply called Pipeline, is a set of plugins,
which supports the integration and use of continuous delivery
pipelines in Jenkins. The continuous delivery pipeline is the process
where automated builds, tests, and deployments are planned and
arranged as one release workflow. Simply put, it is the process the
code changes will go through for delivering software from the version
control to clients and users.

6. What is Jenkinsfile?
A Jenkinsfile is essentially a text file containing the steps for running a
Jenkins Pipeline and is registered into the source control repository of
a project.

7. What is continuous integration in Jenkins?


Continuous integration is the process in which all development work
integration is done at the earliest and a code is continuously tested
after a commit. This process allows one to discover bugs at an early
stage and fix them. The Jenkins build server provides this
functionality.

8. How to change port for Jenkins?


Jenkins, by default, runs on port number 8080. For changing the
existing port from 8080 to the desired port number, we can take the
following steps:

1. Run Jenkins using the command line


2. Execute the command, java -jar -
httpPort=desired_port jenkins.war
If Jenkins is installed using the Windows package, then:

1. Go to Program Files/Jenkins directory


2. Open Jenkins.xml in the editor

Find –httpPort=8080 and replace the port 8080 with the new port
number

9. What are the software prerequisites that must be met


before Jenkins is installed?
First, let us compare Jenkins with TeamCity:
Comparison Jenkins TeamCity
Open Source Yes No
Default security No Yes
Individual validation No Yes
Popularity Widely used Not so widely used

The software prerequisites for installing Jenkins are that first we need
to install Java Development Kit. We also need to install the Jakarta
Enterprise Edition. Jenkins also comes with an embedded Jetty
Runtime that can be used if WebSphere or Tomcat is not available.
Get 50% Hike!
Master Most in Demand Skills Now !
Submit

10. How to configure and use third-party tools in


Jenkins?
These are the steps used for working with a third-party tool in Jenkins:

 First, we have to install the third-party software.


 We need to have the plugin that supports the third-party tool.
 Then, we must configure the third-party tool in the admin console.
 We can then use the plug-in from the Jenkins build job.

11. How to set up a Jenkins job?


First, we need to create a Jenkins job by going to the Jenkins top
page and then selecting a ‘New Job’ and building a freestyle software
project. Some of the elements of a freestyle project include the
following:

 We need a CVS or a subversion where our source code will


reside.
 When Jenkins performs the builds, we will need the optional
triggers.
 We need a build script like a Maven or Ant where the script is
actually built.

If you have any doubts or queries related to DevOps, get them


clarified from DevOps experts on our DevOps Community!

12. How to take a backup of your Jenkins build jobs?


Within the XML configuration, each Jenkins build is stored. When this
folder is copied, the configuration of all the build jobs that are
managed by the Jenkins master is backed up. If we can perform a
Jenkins Git integration, then it is good. When we copy the contents of
the folder, we will see that the build jobs described in the folder will be
restored when the Jenkins server is started the next time.

13. What are the steps included in a Jenkins pipeline?


A complete Jenkins pipeline includes building a project from the
source code, putting it through a variety of units, integrating, testing for
user acceptance and performance, and then finally deploying the
packaged application on an application server.

So, the steps in a Jenkins pipeline can be listed as below:

 Build
 Test
 Deploy

Intermediate Interview Questions

14. What is the process for creating a backup and copy


files in Jenkins?
If we want to create a backup for our file, then we need to regularly
backup our Jenkins_Home directory. This will include all the build jobs
configuration, all the slave node configuration, and the build history. If
we want to create a Jenkins backup, we can copy a job directory to a
clone or can rename the directory.

15. State some of the advantages of using Jenkins.


Here are some of the most important advantages of Jenkins:

 We will get an automated build report every time a change is


made to the source code.
 We will be able to achieve continuous integration with agile
methodology principles.
 We can automate the maven release project with a few simple
steps.
 Bugs can be easily tracked at an early development stage.

16. What are the requirements for using Jenkins?


Some of the requirements for using Jenkins are as follows:

 A source code repository like a Git repository


 A build script like a Maven script that is checked into the
repository


17. What are some of the useful plugins in Jenkins?
Some of the important plugins that are used with Jenkins are:

 Git repository
 Amazon EC2
 HTML Publisher
 JDK Parameter Plugin
 Configuration Slicing Plugin

18. How will you create Pipeline in Jenkins?


The Jenkins Pipeline code is written into a text file called Jenkinsfile,
which in turn is checked into a project’s source control repository.

1. Click on the New Item option on the Jenkins dashboard


2. Create a name for the new item
3. Choose the ‘Pipeline’ project, and click on OK
4. In the Pipeline tab, put the Jenkinsfile code
5. Click on Apply and Save
6. Select Build Now, which will start building the Pipeline

After the Pipeline is set up, any new branches or pull requests that are
created in the repository will be automatically detected by Jenkins,
and it will start running Pipelines for them.

19. How to configure Docker in Jenkins?


To configure Docker in Jenkins, we have to follow the below steps:
1. First, we need to click on Manage Jenkins on the Jenkins
dashboard.
2. We will then select Manage Plugins on the Configuration page.
3. Next, we need to click on Available once in the tabbed interface,
and this will show all the Jenkins plugins available for installation.
4. Then, we will search for a Docker plugin in the search box. There
are multiple Docker plugins to choose from.
5. Finally, we will select the Docker plugin.

20. When can you use the GitHub plugin in Jenkins?


Whenever one wants to integrate Jenkins with GitHub projects, the
GitHub plugin can be used. It is used to enable the scheduling of a
build, pulling data and code files from the GitHub repository to the
Jenkins machine, and triggering every build automatically on the
Jenkins server after each commit on the Git repository. This saves
time and allows one to incorporate the specific project into the CI
process.

21. How to integrate Git with Jenkins?


Before we begin, we need to first have the GitHub Jenkins plugin
installed.

1. Go to Manage Jenkins on the Jenkins dashboard, and then select


Configure System
2. Choose Add GitHub Server in the GitHub section
3. Add the GitHub token as credentials, and Save
4. Open the Jenkins project
5. Tick off the GitHub project checkbox, and give the GitHub
Repository path for the Project URL
6. Under Source Code Management, check the Git box, and in
Repositories, give the GitHub Repository URL
7. Under Build Triggers, check the ‘Build when a change is pushed
to GitHub’ box
8. Set a webhook to Jenkins after the plugin installation is done
9. Go to Settings and then to Integrations & Services from the
GitHub repository
10. Select Add Service, and then add Jenkins (GitHub plugin)
11. The URL of the Jenkins machine should be given as Jenkins
Hook URL. Add /github-webhook/

22. Name some of the SCM tools that are supported by


Jenkins.
Some of the important SCM tools that are supported by Jenkins
include:

 Git
 Subversion
 CVS
 Mercurial

Courses you may like

Advanced Interview Questions


23. Name two ways a Jenkins node agent can be
configured to communicate back with the Jenkins
master.
These are the mechanisms for starting a Jenkins node agent:

 From the browser window, launch a Jenkins node agent


 From the command line, launch a Jenkins node agent

When we launch a Jenkins node agent, it will download a JNLP file. A


new process is launched on the client machine by JNLP when it runs.

24. How to turn off Jenkins Security if the administrative


users have locked out of the admin console?
There is a folder that contains a file named config.xml. We need to
change the settings to false for the security to be disabled when
Jenkins is started the next time.

25. What is the process for securing Jenkins?


First, we need to ensure global security. Then, we have to make sure
that Jenkins is integrated with the user directory through an
appropriate plugin. The project matrix is enabled for fine tuning the
access using the custom version-controlled script for automating the
process of rights and privileges in Jenkins. The access to Jenkins data
or folder is limited. We will run security audits on it.

26. What is the relation between Hudson and Jenkins?


Initially, Jenkins was called Hudson. However, due to some reasons,
the name was changed from Hudson to Jenkins.

27. If there is a broken build in your Jenkins project, then


what will you do?
First, we need to open the console output where the broken build is
created and then see if there are any file changes that were missed. If
we do not find any issues in this manner, then we can update our local
workspace and replicate the problem and then try to solve it.

28. From one server to another, how do you copy or


move your Jenkins jobs?
First, we need to copy our jobs directory from the old to the new
server. There are multiple ways to do it. We can either move the job
from the installation by simply copying the corresponding job directory
or we can make a clone of the job directory by making an existing
job’s copy. For this, we need to have a different name, which we can
rename later.

29. How to schedule builds in Jenkins?


Some steps for scheduling builds in Jenkins are as follows:

 First, we should have a source code management commit.


 We have to complete the other builds.
 Then, we have to schedule it to run at a specified time.
 We need to then give a manual build request.
30. How to configure Jenkins with Maven?
To configure Jenkins with Maven:

1. On the Jenkins dashboard, go to Manage Jenkins, and select


Configure System
2. Scroll down until the Maven section is seen, and then go to Add
Maven
3. Uncheck the ‘Install automatically’ box
4. Add any name for the setting and the location of the
MAVEN_HOME
5. After saving, one can create a job with the ‘Maven project’ option

31. How to create a slave node in Jenkins?


To create a slave node in Jenkins:

1. Go to Manage Jenkins, and scroll down to Manage Nodes


2. Click on New Node
3. Set the node name, choose the Dumb slave option, and then click
on OK
4. Enter the node slave machine details, and click on Save

32. How to deploy from Jenkins?

1. On the Jenkins dashboard, go to Manage Jenkins and then to


Manage Plugins. In the Available section, tick off the ‘Deploy to
Container Plugin’ box and install it. Then, restart the Jenkins
server
2. The next step is to go to the Build project and click on Configure.
Choose the ‘Deploy war/ear to a container’ option
3. In the Deploy war/ear to a container section, enter the server
details on which the files need to be deployed, and press Save

After a successful build, the necessary files will get deployed to the
required container.

You might also like