Jenkins interview questions and answers 👇

  1. Jenkins General Interview Questions
  2. Jenkins Advanced Interview Questions


Jenkins General Interview Questions

What is continuous integration?

View answer

In software development, when multiple developers or teams are working on different segments of same web application, we need to perform integration test by integrating all modules. In order to do that an automated process for each piece of code is performed on daily bases so that all your code get tested.

What is the programming language used to build Jenkins?

View answer

Java

What is the requirement for using Jenkins?

View answer

To use Jenkins you require

  • A source code repository which is accessible, for instance, a Git repository.
  • A working build script, e.g., a Maven script, checked into the repository.

Explain how you can move or copy Jenkins from one server to another?

View answer

  • Slide a job from one installation of Jenkins to another by copying the related job directory.
  • Make a copy of an already existing job by making clone of a job directory by a different name.
  • Renaming an existing job by renaming a directory.

Mention what are the commands you can use to start Jenkins manually?

View answer

To start Jenkins manually, you can use either of the following

  • (Jenkins_url)/restart: Forces a restart without waiting for builds to complete.
  • (Jenkin_url)/safeRestart: Allows all running builds to complete.

Mention some of the useful plugins in Jenkin.

View answer

  • Maven 2 project
  • Amazon EC2
  • HTML publisher
  • Copy artifact
  • Join
  • Green Balls

What is a Cron Job?

View answer

Cron Expression is a utility to schedule job periodically as per the user requirement in Jenkins.

Explain how you can deploy a custom build of a core plugin?

View answer

  • Stop Jenkins.
  • Copy the custom HPI to $Jenkins_Home/plugins.
  • Delete the previously expanded plugin directory.
  • Make an empty file called.hpi.pinned.
  • Start Jenkins.

Explain how can create a backup and copy files in Jenkins?

View answer

Jenkins saves all the setting, build artifacts and logs in its home directory, to create a back-up of your Jenkins setup, just copy this directory. You can also copy a job directory to clone or replicate a job or rename the directory.

Explain how you can clone a Git repository via Jenkins?

View answer

To clone a Git repository via Jenkins, you have to enter the e-mail and user name for your Jenkins system. For that, you have to switch into your job directory and execute the “git config” command.

Can you start Jenkins using command line? How?

View answer

Yes, using jenkins.exe start.

What is a job in Jenkins?

View answer

A job or build job is a task or step in the entire build process. It could be compiling the source code, running unit tests, deploying the application to the web server and so on.

Explain how you can set up Jenkins job?

View answer

To create a project that is handled via jobs in Jenkins. Select New item from the menu, once this done enter a name for the job and select free-style job. Then click OK to create new job in Jenkins. The next page enables you to configure your job.

Mention what are the two components Jenkins is mainly integrated with?

View answer

Jenkin is mainly integrated with two components

  • Version Control system like GIT, SVN.
  • And build tools like Apache Maven.

What is the difference between Hudson and Jenkins?

View answer

There is no difference between Hudson and Jenkins. Hudson was the former name of Jenkins, after going through several issues the name was changed to Jenkins.

What is Groovy in Jenkins?

View answer

Groovy is the default scripting language that is being used in the development of JMeter Version 3.1.

Currently Apache Groovy is the dynamic object-oriented programming language that is used as a scripting language for the Java platform. Apache Groovy comes with some useful features such as Java Compatibility and Development Support.

What is Jenkinsfile?

View answer

The text file where all the definitions of pipelines are defined is called Jenkinsfile. It is being checked in the source control repository.

What is Jenkins Pipeline? What is a CI CD pipeline?

View answer

The pipeline can be defined as the suite of plugins supporting the implementation and integration of continuous delivery pipelines in Jenkins.

Continuous integration or continuous delivery pipeline consists of build, deploy, test, release pipeline. The pipeline feature saves a lot of time and error in maintaining the builds. Basically, a pipeline is a group of build jobs that are chained and integrated in sequence.

What is Quite period in Jenkins?

View answer

Time gap between the builds. In seconds.

How do you delete old builds?

View answer

Delete old builds in following way: Go to –> General tab –> enable ‘Discard old Builds’ checkbox. Here we will set ‘Days to keep builds’ and ‘Max # of builds to keep’

Why do we use Nodes in jenkins?

View answer

  1. Single jenkins server will not handle the whole workload of large and heavier build projects.
  2. Sometimes we may required several different environments to test the builds. This will not be done by a single server.

How do you send the notifications whether build fails or success?

View answer

  1. Configure Email Notification in Configure system under Mange Jenkins.
  2. Email notifications will be configured in job configuration under post-build section.

What is SCM? Which SCM tools are supported in Jenkins?

View answer

  • SCM stands for Source Control Management.
  • SCM module specifies the source code location.
  • The entry point to SCM is being specified as jenkins_jobs.scm.
  • The job specified with ‘scm’ attribute accepts multiple numbers of SCM definitions.

Which CI Tools are used in Jenkin?

View answer

  • Jenkins
  • GitLab CI
  • Travis CI
  • CircleCI
  • Codeship
  • Go CD
  • TeamCity
  • Bamboo

Which Environmental Directives are used in Jenkins?

View answer

Environmental Directives is the sequence that specifies pairs of the key-values called Environmental Variables for the steps in the pipeline.

What are Triggers?

View answer

Trigger in Jenkins defines the way in which the pipeline should be executed frequently. PollSCM, Cron, etc are the currently available Triggers.

What is Agent Directive in Jenkins?

View answer

The Agent is the section that specifies the execution point for the entire pipeline or any specific stage in the pipeline. This section is being specified at the top-level inside the pipeline block.

How will you define Post in Jenkins?

View answer

Post is a section that contains several additional steps that might execute after the completion of the pipeline. The execution of all the steps within the condition block depends upon the completion status of the pipeline.

The condition block includes the following conditions – changed success, always, failure, unstable and aborted.

What are Parameters in Jenkins?

View answer

Parameters are supported by the Agent section and are used to support various use-cases pipelines. Parameters are defined at the top-level of the pipeline or inside an individual stage directive.

What is Flow Control in Jenkins?

View answer

In Jenkins, flow control follows the pipeline structure (scripted pipeline) that are being executed from the top to bottom of the Jenkins file.

What are the basic requirements for installing Jenkins?

View answer

  • Java 7 or above.
  • Servlet 3.1
  • RAM ranging from 200 MB to 70+ GB depending on the project build needs.
  • 2 MB or more of memory.

What is the use of Backup Plugin in Jenkins?

View answer

Jenkins Backup Plugin is used to back up the critical configurations and settings in order to use them in the future in case of any failure or as per the need of time.

What is Maven? What is the benefit of integrating Maven with Jenkins?

View answer

Maven is a build management tool. It uses a simple pom.xml to configure all the dependencies needed to build, test and run the code. Maven manages the full lifecycle of a test project. Once integrated with Jenkins, the maven Webdriver will build the project and execute all tests efficiently.

Jenkins Advanced Interview Questions

How can you clone a git repository via jenkins?

View answer

If you want to clone a Git repository via Jenkins, you have to enter the e-mail and user name for your Jenkins system. Switch into your job directory and execute the “git config” command for that.

What are the various ways in which build can be scheduled in Jenkins?

View answer

  • By source code management commits.
  • After completion of other builds.
  • Can be scheduled to run at a specified time (crons).
  • Manual Build Requests.

What is Kubernetes? How can you integrate Jenkins with Kubernetes?

View answer

Kubernetes is a container orchestration tool. With Kubernetes, one can create multiple container instances to achieve more fault tolerance. You can use the Kubernetes deploy plugin to use it with Jenkins for continuous deploy.

Let us say, you have a pipeline. The first job was successful, but the second failed. What should you do next?

View answer

You just need to restart the pipeline from the point where it failed by doing ‘restart from stage’.

What is the use of JENKINS HOME directory?

View answer

All the settings, logs and configurations are stored in the JENKINS_HOME directory.

How does Jenkins authenticate users?

View answer

There are 3 ways:

  • The default way is to store user data and credentials in an internal database.
  • Configure Jenkins to use the authentication mechanism defined by the application server on which it is deployed.
  • Configure Jenkins to authenticate against LDAP server.

How can you use a third-party tool in Jenkins?

View answer

Below are the steps used for working with a third-party tool in Jenkins.

  • First install the third-party software.
  • Download the plug-in that supports the third-party tool.
  • Configure the third-party tool in the admin console.
  • Then use the required plug-in from the Jenkins build job.

What are the types of pipelines in Jenkins?

View answer

There are 3 types:

  • CI CD pipeline (Continuous Integration Continuous Delivery)
  • Scripted pipeline
  • Declarative pipeline

What is DevOps and in which stage does Jenkins fit in?

View answer

DevOps is a software development practice that blends software development (Dev) with the IT operations (Ops) making the whole development lifecycle simpler and shorter by constantly delivering builds, fixes, updates, and features. Jenkins plays a crucial role because it helps in this integration by automating the build, test and deployment process.

What is a DSL Jenkins?

View answer

The Jenkins “Job DSL / Plugin” is made up of two parts – first, The Domain Specific Language (DSL) itself that allows users to describe jobs using a Groovy-based language, and second, a Jenkins plugin which manages the scripts and the updating of the Jenkins jobs which are created and maintained as a result.

How do you create Multibranch Pipeline in Jenkins?

View answer

The Multibranch Pipeline project type enables you to implement different Jenkinsfiles for different branches of the same project. In a Multibranch Pipeline project, Jenkins automatically discovers, manages and executes Pipelines for branches that contain a Jenkinsfile in source control.

What are the types of jobs or projects in Jenkins?

View answer

These are the types of jobs/projects in Jenkins –

  • Freestyle project
  • Maven project
  • Pipeline
  • Multibranch pipeline
  • External Job
  • Multi-configuration project
  • Github organization

What is blue ocean in Jenkins?

View answer

It is a project that was started with the purpose to rethink the user experience of Jenkins, modeling and presenting the process of software delivery by surfacing information that’s important to development teams. This is done with as few clicks as possible, while still staying true to the extensibility that is core to Jenkins. While this project is in the alpha stage of development, the intent is that Jenkins users can install Blue Ocean side-by-side with the Jenkins Classic UI via a plugin.

What is Continuous Testing?

View answer

Continuous Testing is the process where you execute automated tests as part of the software delivery pipeline. This is done so that you get the feedback on the business risks associated with software as early as possible. It consists of evolving and extending test automation to address the increased complexity and pace of modern application development and delivery.

Continuous Testing means that testing takes place on a continuous basis without any disruption of any kind. In a Continuous DevOps process, a software change is continuously moving from Development to Testing to Deployment. The code undergoes continuous development, delivery, testing and deployment.

How can you temporarily turn off Jenkins security if the administrative users have locked themselves out of the admin console?

View answer

The JENKINS_HOME folder contains a file named config.xml. When you enable the security, this file contains an XML element named useSecurity that changes to true. If you change this setting to false, security will be disabled the next time Jenkins is restarted.

false

However, we must understand that disabling security should always be both a last resort and a temporary measure. Once you resolve the authentication issues, make sure that you re-enable Jenkins security and reboot the CI server.

What do you mean by Pipeline as a Code?

View answer

Pipeline as Code describes a set of features that allow Jenkins users to define pipelined job processes with code, stored and versioned in a source repository. These features allow Jenkins to discover, manage, and run jobs for multiple source repositories and branches — eliminating the need for manual job creation and management.

What are the ways to configure Jenkins node agent to communicate with Jenkins master?

View answer

Below mentioned ways help you to start the node agent –

  • Command-line – For this, the client needs the executable agent.jar file. It helps to launch the process on the client to communicate with the Jenkins master to run build jobs.
  • Browser – This file launches a new process on the client machine to run jobs.

What is the tool used for provisioning and configuration?

View answer

Ansible is an agent-less configuration management and orchestration tool. In Ansible, the configuration modules will be called as Playbooks. Like other tools, Ansible will be used to cloud provision.

How can you decide the no. executors?

View answer

No. Executors is number of parallel jobs, based on requirement If we required, jenkins should run at max 5 parallel jobs we will provided the number at No. executors.

Manage Jenkins → Configure system → Number of parallel jobs: 5

Where did your plugins come from Jenkins?

View answer

Plugins can be downloaded from plugins.jenkins.io site

Is it possible to exchange jobs between two different jenkins?

View answer

Yes, it is possible by using ‘Job Import’ plugin. We will exchange the job between two jenkins. We required providing the source instance (Jenkins) URL. We will import a particular job and all the jobs and also views.

Which plugin is required to deploy a .war file into application server?

View answer

‘Deploy to Container Plugin’ is required to deploy a.war file into application server.

How to re-execute a parameterized build without entering the parameter value when the job fails?

View answer

‘Rebuild plug-in’ will allow the user to rebuild a parametrized build without entering the parameters again.

How master system will communicate to slave system?

View answer

Using ‘slave.jar’ file in slave system master system will communicate to slave system. This file must be present in slave to communicate with.

How do you make a job to run only on slave node?

View answer

Go to job configuration tab –> under ‘General’ section enable ‘Restrict where this project will be run’ then we will provide the lable name of the node.

How do you make all the jobs to be run only on slave node?

View answer

Go to –>’Manage jenkins’ –> ‘configure system’ –> at ‘Labels’ mention the node system label.

What is SCM Checkout retry count?

View answer

It can check the code in SCM tool twice in between the builds, if the value is 2.

What are stages?

View answer

Stage – Containing a sequence of one or more stage directives, the stages section is where the bulk of the “work” will be described by a Pipeline can be located. At a minimum it will be recommended which stages will contain at least one stage directive for each discrete part of the continuous delivery process, like Build, Test, and Deploy.

What is Parallel in Jenkins?

View answer

Stages in Declarative Pipeline will declare a number of nested stages within them, which will be executed in parallel. A stage should have only one of either steps or parallel. The nested stages cannot have further parallel stages themselves, otherwise behave the same as any other stage. Any stage which contains parallel cannot have agent or tools, since those are not relevant without steps.

What is matrix-based security?

View answer

Matrix-based security is one of the approval techniques accessible for verifying Jenkins. It enables you to give explicit consent to clients and gatherings. The accessible authorizations are recorded beneath with their portrayals and are additionally accessible by floating over the consent heading in the Jenkins UI.

What is a Snippet Generator?

View answer

Snippet Generator is a utility for creating bits of code for individual steps provided by the plugin and it is dynamically populated with a list of the steps available to the Jenkins instance.