Jenkins Interview Questions

Prepare better with the best interview questions and answers, and walk away with top interview tips. These interview questions and answers will boost your core interview skills and help you perform better. Be smarter with every interview.

  • 4.6 Rating
  • 37 Question(s)
  • 40 Mins of Read
  • 69854 Reader(s)

Beginner

Continuous Integration is building software and testing it thoroughly as much as possible with every change. It is a development practice in which developers integrate code into shared repository multiple times and each check-in is tested for build and if there any problems detected, it is resolved immediately.

CI is the software engineering principle which follows that any change in code that is committed to the version control system will trigger automatically the compilation process on a CI tool like Jenkins or TeamCity, which results in a build artifact if its build manifest prescribes or successfully completes if otherwise. In case of compilation failure, the build process errors out which can be notified to concerned with help of CI tool. Additionally, the CI process can have testing included as part of it as well.

  • Defects could be found early and it takes less cost less to fix 
  • Reduced Time to Market as software is already tested and is always ready to move to further environments. 
  • Increased Productivity
  • Improved Quality & Lowered Costs
  • Default Mechanism - Choose an internal database to store user data and credentials. 
  • Authenticate against a Lightweight Directory Access Protocol (LDAP) server.
  • Use the authentication mechanism used by the application server upon which it is deployed.

Jenkins is an open source automation server written in Java. It is used for automation of SDLC . It supports version control tools like CVS, Subversion, Git and Perforce. It is a free software used for there are multiple plugins for Jenkins that could be used for projects written in languages other than java.

In Continuous Delivery pipeline automated builds, tests and deployments are orchestrated as one release workflow. It is a set of steps for making changes in application in test, dev and finally in production environment in an automated manner. 

  • Software developer commits code to the Source Code Repository like Github.
  • Jenkins server will check the repository on regular intervals for changes.
  • As soon as changes are committed, Jenkins will pull those changes and starts the build process instantly.
  • If the build is not successful then the developer team will be notified. 
  • If the build is successful then the build will be deployed to the test server.
  • Once the testing is complete, Jenkins will send the feedback and developers are notified for the new build or test results.
  • Jenkins server monitors the repository regularly and the above process will be repeated.
  • Version Control system like Git,SVN
  • Build tools like Apache Maven.

Hudson was the earlier name and version of current Jenkins.  

Jenkins is a Continuous-Integration tool that runs periodic builds and tests of code, while Maven and Ant are tools that actually does the build. Maven and  Ant Tools also provide dependency management and project management. Jenkins can use Maven as a build tool. It is possible to use both at the same time and it is certainly possible to use Jenkins without Maven.

It supports Git , Subversion , CVS ,Mercurial,  AccuRev, Perforce, Clearcase and RTC.

 You can get the password by accessing -.jenkins/secrets/initialAdminPassword remotely.

  • Continuous Integration and Continuous Delivery 
  • Easy installation 
  • Easy configuration 
  • Support for around 400 Plugins 
  • Extensible - Jenkins uses plugin architecture, providing nearly infinite possibilities for what Jenkins can do.
  • Distributed - Jenkins can easily distribute work across multiple machines, helping drive builds, tests and deployments across multiple platforms faster.

Jenkins is an open-source continuous integration software tool written in the Java programming language for building and testing changes in a larger code base in real time. It enables developers to find and solve defects in a code base rapidly and to automate testing of their builds. It is a software which allows Continuous Integration where developers integrate code into a shared repository at regular intervals to remove the problem of issues in the build cycle later.

A Continuous Integration and Deployment Pipeline (CD/CI) is a very important aspect of a software project. It saves manual works and helps in creating high-quality software for continuous integration, automated tests, and code metrics.

Builds can be triggered by many methods - By committing in a version control system, by scheduling using cron mechanisms and by requesting a specific build URL. It can also be triggered after the other builds in the queue have completed. 

In Jenkins Console under (Build Triggers - Build periodically – Schedule) schedules for Jenkins to build periodically or on a specific date/time can be set. To set periodically scheduled Jenkins jobs one should schedule under Configure - Build Triggers - Build periodically – Schedule.

Examples:

Build every hour  - H * * * *

Build every 15 minutes - H/15 * * * *

Jenkins build schedule syntax

 ┌───────────── minute (0 - 59)

 │ ┌───────────── hour (0 - 23)

 │ │ ┌───────────── day of month (1 - 31)

 │ │ │ ┌───────────── month (1 - 12)

 │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday;

 │ │ │ │ │                                       7 is also Sunday on some systems)

 │ │ │ │ │

 │ │ │ │ │

 * * * * *  schedule command to execute

Jenkins is based on distributed architecture called the master-slave architecture. It has a Master server which is responsible to pull the code every time there is a commit from the source code repository. It uses the TCP/IP protocol to assigns the work-loads to each of it slave machines. , Jenkins master assigns the work load to each of its slaves.

Jenkins Slave Nodes are small Java Client processes that connect to a Master Jenkins instance over the Java Network Launch Protocol (JNLP). It is used for running build tasks.

Advanced

  • Most widely used tool for managing continuous integration builds and delivery pipelines. 
  • Helps developers in building and testing software continuously. 
  • Requires little maintenance and has built-in GUI tool for easy updates. 
  • Provides customized solution and there are over 400 plugins to support building and testing virtually any project.
  • One can configure alerts in several ways to receive email notification, pop-ups, etc. and actually automate it. 

Jenkins has a built-in command line interface that allows users and administrators to access Jenkins from a shell environment. Jenkins CLI helps for easy scripting of routine tasks, bulk updates, and troubleshooting. The command line interface can be accessed over SSH or with the Jenkins CLI client.

Jenkins includes job configs, build logs, plugins, plugin configuration etc. which needs to be backed up regularly. Two popular methods for backing up ar given below

  1. Jenkins Backup Using Thin Backup Plugin backs up all the data based on the schedule which also handles the backup retention.
  2. Jenkins Backup Using Disk Snapshots - As Jenkins does not have any database, attach an external disk to Jenkins server, mount the server on a folder and perform Point In time snapshots or backups.

An agent in Jenkins describes the complete pipeline or a particular stage where execution will take place or where the agent is located. 

An agent in Jenkins describes the complete pipeline or a particular stage where execution will take place or where the agent is located. 

Go to Jenkins top page, select “New Job”, then choose “Build a free-style software project”.

 One can customize the various elements of this freestyle job:

  •  Optional SCM, such as CVS or Subversion where your source code resides.
  •  Optional triggers to control when Jenkins will perform builds.
  •  Choose build script that performs the build like ant, maven or shell script where the real work happens.

Below are the steps to deploy a custom build of a core plugin:

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

If any broken build is found then check the local workspace immediately and try to fix it quickly.

Running Selenium tests in Jenkins allows you to run your tests every time your software changes and deploy the software to a new environment when the tests pass. Jenkins can schedule your tests to run at specific time.

Access the Jenkins Dashboard and perform the below steps:

  1. Navigate to the "Settings" tab.
  2. Select the "Webhooks" option on the left menu.
  3. Click "Add Webhook"
  4. Select "application/json" as the encoding type.
  5. Leave "Secret" blank in Github section

Complete sequence of the key-value pairs that could be defined as the environment variables for different steps where the environment directive is located within the pipeline.

Triggers are defined in Jenkins to re-trigger the pipeline in multiple automated ways. eg:cron,pollSCM and upstream.

This directive allows to prompt a user input in a build stage. It displays a message and waits for the user input. Once the input is approved,  the stage will trigger further deployments.

This is a directive which allows to run nested stages in parallel and are defined and executed together. However, there are some restrictions like "Within a parallel directive you cannot nest another parallel directive"

Scripted pipeline is built on the top of the underlying pipeline sub-system. It is a general-purpose language based on Groovy and provides the same features and benefits of Groovy.It is a highly flexible tool that results in multiple continuous delivery pipelines.

Execution of scripted pipelines are executed in a sequential order from top to the downwards is called as control flows in the pipeline.

The below steps need to be followed.

  • Move 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 a clone of a job directory by a different name
  • Renaming an existing job by renaming a directory.

Jenkins is an open-source continuous integration tool for testing and reporting on isolated changes in a larger code base in real time. It enables developers to find and solve defects in a code base rapidly and to automate testing of their builds.

From Jenkins installation directory execute the below commands

stop:

jenkins.exe stop

start:

jenkins.exe start

restart:

jenkins.exe restart

Additionally, we can have start, stop, restart mentioned at end of the Jenkins URL to do the same

.https://jenkins_URL/start, https://jenkins_URL/stop, https://jenkins_URL/restart

  • Go to the directory where you installed the Jenkins 
  • Open the Jenkins.xml from the Jenkins directory.
  • Search “–httpPort=8080” and replace the “8080” with the new port number if you have defined.

Description

Prepare better with the best interview questions and answers, and walk away with top interview tips. These interview questions and answers will boost your core interview skills and help you perform better. Be smarter with every interview.
Levels