Top 50 Interview questions on CI/CD – Jenkins
1) What is Jenkins?
Jenkins is a Continuous Integration tool and automation server to monitor continuous integration and delivery and It is written in Java.
It is known as an automated Continuous Delivery tool that helps to build and test the software system with easy integration of changes to the system. Jenkins follows Groovy Scripting.
Also, it enables developers to continuously check in their code and also analyze the post-build actions. The automation testers can use to run their tests as soon as the new code is added or code is modified.
2) What are the features of Jenkins?
- Free open source.
- Easy installation on various operating systems.
- Build Pipeline Support.
- Workflow Plugin.
- Test harness built around JUnit.
- Easy upgrades.
- Rapid release cycle.
- Easy configuration setup.
- Extensible with the use of third-party plugins.
3) Why do we use Jenkins?
It is used to continuously monitor the large code in real-time. It enables developers to find bugs in their code and fix them. Email notifications are made to the developers regarding their check-ins as a post-build action.
4) Mention some of the important plugins in Jenkins?
- Git
- Maven 2 Project
- HTML Publisher
- Copy Artcraft
- Join
- Green Balls
- Amazon EC2
5) What is Continuous Integration in Jenkins?
Continuous integration is the process of continuously checking-in the developer’s code into a version control system and triggering the build to check and identify bugs in the written code.
6) What are the prerequisites for using Jenkins?
- A source code repository which is accessible, for instance and for a Git repository.
- A working build script like Maven script, checked into the repository.
7) What is the difference between Hudson and Jenkins?
There is no difference between Hudson and Jenkins. Hudson was the initial name of Jenkins, after going through several issues the Hudson name was changed to Jenkins.
8) How do you install Jenkins?
you just need to follow these five steps:
- Install Java Version 8 – Java is a must because Jenkins is a Java based application.
- Install Apache Tomcat Version 9 – It is essential to deploy a Jenkins war file.
- Download Jenkins war File – This Jenkins war file is must to install.
- Deploy Jenkins war File – using Tomcat you deploy Jenkins war file to run Jenkins.
- Install Suggested Plugins – Install a default list of plugins suggested by Jenkins.
9) What is Maven? What is the advantage of integrating Maven with Jenkins?
It is a build management tool. It uses simple pom.xml to configure all the dependencies needed to build, test and run the code. It manages the full lifecycle of a test project. Once the project is integrated with Jenkins, the maven Webdriver will efficiently build the project and execute all tests.
10) How to start Jenkins manually.
To start Jenkins manually open Console or a Command line, then go to your Jenkins installation directory. Then use the below commands:
Start Jenkins: jenkins.exe start
Stop Jenkins: jenkins.exe stop
Restart Jenkins: jenkins.exe restart
11) Which SCM tools Jenkins supports?
- AccuRev
- CVS
- Subversion
- Git
- Mercurial
- Perforce
- Clearcase
- RTC
12) What are the SCM tools that Jenkins supports?
The Source Code Management tools that Jenkins supports are SVN, Clearcase, CVS, Git, AccuRev, Perforce, RTC, Mercurial.
13) What is a job in Jenkins?
A 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.
14) How can you create a job?
To create a job go to the dashboard page, then select a ‘New Job’, you may choose options like SCM, triggers to control, the build script and notifications.
15) What is meant by Jenkins pipeline?
A pipeline is a group of interlinked jobs done one after the other in a sequence. To integrate and implement continuous delivery pipelines, Jenkins pipelines provides a combination of plugins. The instructions to be performed are given through code. A continuous delivery pipeline was represented as –
16) What are the types of pipelines in Jenkins?
There are 3 types –
- CI CD pipeline (Continuous Integration Continuous Delivery)
- Scripted pipeline
- Declarative pipeline
17) What syntax does Jenkins use to schedule build jobs or SVN polling?
The cron syntax.
Cron syntax is represented using five asterisks; each asterisk is separated by a space. The syntax is as follows – [minutes] [hours] [day of the month] [month] [day of the week]. Example, if you want to set up a cron for every Monday at 11.59 pm, it would be
59 11 * * 1
18) Have you created a build job in Jenkins? Explain how to do it.
Yes. The simple steps are –
- Click on New Item on the Dashboard.
- Select the freestyle project option
- Specify the details of the job like SCM, build triggers, advanced options and more
- It is important to specify the location of files that should be built.
- Once all the settings are marked, click on the ‘Add build step’ and select the appropriate option you want.
- Then Click on Build now for saving the build.
19) What is the use of JENKINS_HOME directory?
All the settings, configurations and logs are stored in the JENKINS_HOME directory.
20) What is a backup plugin? Why is it used?
Backup plugin is used to take backups of all the critical settings and configurations to be used in the future. This is mostly useful when there is a failure so that we don’t lose any settings.
21) Have you run automated tests on Jenkins? How is it done?
Yes. It can be run through tools like Selenium or maven. Developers can schedule the test runs. Then it tests the results and sends a report to the developers.
22) What is the difference between Jenkins, Maven, and Ant?
Jenkins | Maven | Ant |
Continuous Integration Tool | Build automation tool | Command Line/Java Library Tool. |
Automates software development process through continuous integration and facilitates continuous delivery. | Describes software dependencies and explains how the software is built | Drives build process |
Supports version control tools like Git, AccuRev. | Supports projects written in C#, Ruby. | Supports projects written in C and C++. |
23) What are the Parameters in Jenkins?
Parameters are supported by the Agent section. They are used to support several use-cases pipelines and are defined at the top-level of the pipeline or inside an individual stage directive.
24) What is the use of Agent Directive?
It specifies Jenkins how and where to execute the entire pipeline. The directive is specified at the top-level inside the pipeline block and stage-level usage is optional.
25) What is flow control in Jenkins?
Flow control supports the pipeline structure (scripted pipeline) for executing the top to bottom of the Jenkins file.
26) How do I clone a git repository using Jenkins?
You have to enter the user name and email for your Jenkins system and turn into your job directory and execute the “git config” command for that.
27) What are scripted pipelines?
Scripted pipelines are writing Jenkins pipelines as code in a traditional way. The scripted pipeline is defined within a ‘node’.
Syntax of the Scripted Pipeline:
The node is a part of the Jenkins architecture, where there are two types of a node, the agent / node will run the part of the workload of the jobs and the master node will handle the configuration of the job.
28) What does SCM mean in Jenkins?
Source Code Management specifies the source code location in Jenkins. jenkins_jobs.scm is The entry point to SCM. Some of the SCM tools are CVS, Git, Perforce, AccuRev, Subversion, Clearcase, RTC, and Mercurial.
SCM can be defined as:
scm:
name: eloc – scm
scm:
git:
url: ssh://Jenkins.org/eloc.git
29) How You Can Clone A Git Repository Via Jenkins?
To clone a Git repository via Jenkins, you have to enter the email and username for your Jenkins system. For that you have to switch into your job directory and execute the git command.
30) What Are The Two Components Jenkins Is Mainly Integrated With?
Jenkins is integrated with these two components:
- Version Control system like GIT,SVN
- And build tools like Apache Maven.
31) What is Groovy in Jenkins?
Groovy is the default scripting language that is being used in the development of JMeter Version 3.1.
Currently Apache Groovy is a dynamic object-oriented programming language. It is used as a scripting language for the Java platform and it comes with some useful features such as Development Support and Java Compatibility.
32) Tell Me Jenkins Installation Requirements?
- It requires Java7 or above and Servlet 3.1 to function.
- Java8 is recommended.
- To operate well Jenkins requires a fair amount of memory.
- Smaller installations should start around 256MB1GB.
33) What You Do When You See A Broken Build For Your Project In Jenkins?
I will open console output for build and will try to see if any file changes were missed.
If not able to find the issue in that way, Will clean and update the local workspace to replicate the problem on the local and will try to solve it.
34) How Can You Move Or Copy Jenkins From One Server To Another?
- Firstly, copy the job directory and slide a job from one installation of Jenkins to another installation of Jenkins.
- Make a copy of a job which already existed by making a clone of a job directory by a different name.
- Renaming an existing job by rename a directory.
35) How to schedule builds in Jenkins?
Follow are the steps for scheduling builds in Jenkins:
- Main, 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 give a manual build request .
36) What is the process for securing Jenkins?
First, we need to ensure global security. Later, 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. We will run security audits on it.
37) What is the process for creating a backup and copy files in Jenkins?
If we want to create a backup for a file, then we need to backup regularly our Jenkins_Home directory. This will include all the slave node configuration, all the build jobs configuration, and the build history. If we want to create a backup for Jenkins, we can copy a job directory to a clone or can rename the directory.
38) 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.
Here some of the elements of a freestyle project :
- We need a CVS or a subversion where our source code will reside.
- We will need the optional triggers, when Jenkins performs the builds.
- Where the script is actually built, we need a build script like a Maven or Ant.
39) What are the advantages of Jenkins?
Advantages of Jenkins are as follows:
- Build failures are cached during the integration stage.
- Notifies the developers about build report status using LDAP (Lightweight Directory Access Protocol) mail server.
- Maven release projects are automated with simple steps.
- Easy bug tracking.
- Automatic changes get updated into the build report with notification.
- Supports Continuous Integration in agile development and test-driven development.
40) 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. It will be disabled when Jenkins is started the next time
41) 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.
Below are the steps in a Jenkins pipeline:
- Build
- Test
- Deploy
42) How to configure and use third-party tools 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.
- Then we can use the plug-in from the Jenkins build job.
43) How do you integrate Git with Jenkins?
Below steps show how to integrate Git with Jenkins:
- Manage Jenkins button on your Jenkins dashboard.
- Click on Manage Plugins.
- In the Plugins Page
- You can select the GIT Plugin and then click on Install without restart.
- You can also select the Download now option and install after restart.
- If you already have the Git plugin installed, you will see a “No updates available” message.
- Go to Manage Jenkins on your Jenkins dashboard.
44) What is Jenkinsfile?
The text file where all the pipeline definitions are defined is called Jenkinsfile. we can check in the source control repository.
45) What is the difference between Continuous Integration, Continuous Delivery, and Continuous Deployment?
The diagrammatic representation given below can elaborate on the differences between Continuous Integration, Continuous Delivery, and Continuous Deployment more precisely.
Continuous Integration:
(It involves keeping the latest copy of the source code at a commonly shared hub where all the developers can check to fetch out the latest change in order to avoid conflict.)
Continuous Delivery:
(Manual Deployment to Production. It does not involve every change to be deployed.)
Continuous Deployment:
(Automated Deployment to Production. Involves every change to be deployed automatically.)
46) What are Declarative Pipelines in Jenkins?
Declarative Pipelines are the newest additions to Jenkins that simplify the groovy syntax of Jenkins pipelines (top-level pipeline) with some exceptions, such as:
No semicolon to be used as a statement separator. The top-level pipeline should be enclosed within block viz;
The common syntax is:
pipeline {
/* Declarative Pipeline */
}
47) Which CI Tools are used in Jenkin?
Jenkins supported the following CI tools:
- Jenkins
- GitLab CI
- Travis CI
- CircleCI
- Codeship
- Go CD
- TeamCity
- Bamboo
48) What are Triggers?
It is in Jenkins that defines the way in which the pipeline should be executed frequently. PollSCM, Cron, etc are the currently available Triggers.
49) What is Agent Directive in Jenkins?
The Agent is the section that specifies the execution point for the entire pipeline or any specific stage in the pipeline. This section is specified at the top-level inside the pipeline block.
50) How will you define Post in Jenkins?
It is a section that contains several extra steps that might execute after the completion of the pipeline. All the execution 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.