The blogs provides the common asked interview questions on Jenkins when appeared for DevOps development in IT job opening. Jenkins helps in automatically the build process for developers once the code is check-in to the Source Code Repository
Jenkins Interview Questions and Answers
1) What is Continuous Integration in DevOps ?
DevOps supports Continuous Integration and Continuous Development (CI /CD) as a process which enables developers to provide the code fix for the raised defects on priority. Once the code changes are merged into the Version Control System, automatic build deployment process gets started. This allows developers to quick check the build errors and make corrections.
Continuous Integration allows to perform the below activities:
- Automated build deployment process
- Allows to executes Junit test cases
- Allows to validate business scenarios by invoking APIs to test the functional test cases
- Allows to generate build and process related reports
- Allows easy integration with other DevOps Tool
2) What is Jenkins and why it is commonly used ?
Jenkins is the open source continuous integration (CI) tool which tracks the source version control , automate the build process once the code is checked in to the source code repository , monitor the build process, sends notifications and alerts in case of build failures.
Jenkins allows to integrate plug-ins for Junit testing, coding standard violations, Junit Code Coverage , etc. and helps to get the integrated testing done before it is being mad available as the new build for testers and business users.
3) Describe the features of Jenkins ?
The below given are the features of Jenkins
- Jenkins is a open source continuous integration tool
- Jenkins is one of the most commonly used tool for Continuous Integration and Continuous Development (CI /CD)
- Jenkins can be installed on heterogenous environments supporting different operating system
- Jenkins can be easily distributed among different machines
- Jenkins provide extensibility by integrating plug-ins
- Jenkins provides easy configuration setup
- Jenkins provided pipeline support
- Jenkins can be easily upgraded
- Jenkins can be integrated with other DevOps tool
- Jenkins provide easy documentation
4) Provide advantages of using Jenkins ?
Jenkins provide the below given advantages
- Easy to use code integration and build deployment process
- Allows to perform harness test by integrating Junit test cases
- Jenkins is a free open source tool
- Jenkins provides platform independence
- Jenkins provide numerous plug-ins to integrated and support DevOps Development Activities
- Build errors / bugs can be tracked in the early stage of deployment
- Successful builds with same version can be deployed to higher environments with ease
- Build notifications with build status and build errors helps in code fix and improving overall integration process
5) What are the pre-requisites to install Jenkins ?
Jenkins can be installed on Windows, Linux and MacOS. Jenkins can be integrated with Docker by uploading the latest Jenkins Image to run as the “container” . Docker can also be integrated easily with Kubernetes.
Jenkins uses Application Server as Jetty to run as a standalone application within its own process with the built-in Java Servlet Container
The below system requirements need to be checked before installing Jenkins
- Minimum of 256MB of RAM
- Minimum of 1GB Disk space
- Jenkins can be installed using Java 8 and Java 11 only for both 32-bit and 64-bit versions.
- Java 9 , Java 10 and Java 12 are not yet supported
- Jenkins support Open JDK 8 and Open JDK11
6) How maven integration with Jenkins is useful ?
Maven is a build management tool which stores all the build dependencies in pom.xml which helps in building, testing and running the code. Maven support the project testing life cycle and thus when integrated with Jenkins, it becomes useful to test the project code changes during the deployment process to identify the build specific errors
7) Name few integrated plugins with Jenkins ?
The below given are the few plugins that can be integrated with Jenkins
- Pipeline : REST API
- GitHub Branch Source
- Bitbucket Branch Source
- Junit Attachments
- Amazon S3 Publisher
- AWS Code Commit Trigger
8) What is Jenkins Pipeline ?
Jenkins Pipeline is a combination of plugins which support in implementing continuous delivery pipelines into Jenkins
Jenkins supports Continuous Delivery (CD) process by automating the build process by retrieving the latest source version and deploying it to become it available for business users and customers.
Jenkins Pipeline uses the https://www.jenkins.io/doc/book/pipeline/syntax/ to execute as a “code” to make the deployment process simple for even complex scenarios also. Jenkins Pipeline defines the build process in the test file Jenkinsfile and commits the text file in the project source control repository. Jenkinsfile performs the below steps:
- Automates the Pipeline build process for pull requests from all branches
- helps in code review
- Provides audit trail for the Pipeline
- Common repository for the Pipeline even though multiple code commits
9) Describe syntax types supported by Jenkinsfile ?
Jenkinsfile can be written using below given syntax
- Declarative Pipeline Syntax: Provides more syntax features and helps in reading and writing the code in a easy way. The top-level of the Pipeline must be a block with Pipeline { } . The Blocks supports only Sections, Directive, Steps and assignment statements. Does not support Semicolon as statement separators
- Scripted Pipeline Syntax: Scripted Pipelines Syntax is built using Groovy and provides all possible features of Groovy which helps in implementing continuous delivery process . Scripted Pipeline executes the Jenkinsfile in the top-bottom hierarchy model . Scripted Pipeline handles conditions using if-else and captures the exceptions using try-catch blocks.
10) Which commands can be used to start Jenkins manually ?
The below given commands can be sued to restart Jenkins manually
- (<JENKINS_ENVIRONMENT_URL>)/restart: enables the force start even if the build is in progress
- (<JENKINS_ENVIRONMENT_URL>)/safeRestart: enables restart when all running build get completed
11) What are the available build statuses in Jenkins ?
The Jenkins provides the below given build status
- Aborted: When the build is time-out or manually stopped by the user
- Failed: When the build deployment stopped due to fatal error
- Stable: When the build is successful
- Unstable : When the build was successful but it got Junit test failed
- Successful : When build has compiled with No errors
12) Name few SCM Tools supported by Jenkins ?
The below given SCM Tools can be integrated with Jenkins
- Git
- Clearcase
- CVS
- SubVersion
- Mercurial
13) How to start Jenkins using command-line ?
The Jenkins can be started from command line using jenkins.exe
14) What is a job in Jenkins ?
The term job is deprecated in Jenkins and now it is called as Project.
A job or project is a set of task defined for Jenkins to consider during the Continuous Integration deployment process . A task could be source code compilation, Junit Code Coverage, executing Junit Test Cases, deployment to the specific web server, etc.
15) Describe to build a job in Jenkins ?
The below steps can be provided to build a job:
- Click on Jenkins Dashboard -> New Item
- Select Freestyle Project Option
- Provide job details like build triggers, SCM, etc.
- Provide the file location that need to be part of the build job
- Click ‘Add Build Step’ and select the build option
- Click ‘Build Now’ . This saves the build configuration and run the build
16) How to integrate a 3rd party tool in Jenkins?
The below steps can be performed in Jenkins to integrate 3rd Party tool
- Install the Node
- Install the Jenkins plugin code from Jenkins Admin Console
- Navigate to Admin-> Manage -> Configure Settings
- Configure Node to build job in the Jenkins Pipeline
17) Explain user authentication process in Jenkins ?
The below steps can be performed in Jenkins to authenticate users
- Persist the user credentials in the database
- Configure Jenkins to authenticate user using LDAP Server
- Configure Jenkins to authenticate user defined by the server where Jenkins is deployed
18) Difference between Jenkins and Bamboo ?
Jenkins Deployment | Bamboo Deployment |
Jenkins is an open source continuous integration tool | Bamboo requires commercial continuous integration tool |
Jenkins plugins and development release is supported by Jenkins Community | Bamboo Development Team owns the changes |
Due to multiple plugin and SCM Tool integration, Jenkins is less user friendly interface | Bamboo provides user friendly interface |
Provides multiple plugins for integration | Bamboo provides more built-in functionality and less plugins |
19) Explain Multibranch Pipeline in Jenkins ?
The below given steps can be performed for creating multibranch pipeline in Jenkins
- Click on Jenkins Dashboard -> New Item
- Provide the Project Name
- Select ‘Multibranch Pipeline’ as an option
- Select source code repository location and provide credentials
- Save the Project
- Jenkins creates multibranch Pipeline for repository and pull requests from the branches
- To connect to repository we need URL from repository settings called as HookURL
- Add the HookURL to Webhooks section
- Jenkins can now automatically run the build
20) Difference between Jenkins, Maven and Ant ?
Jenkins | Maven | Ant |
Jenkins is a continuous integration tool | Maven is a Build Management Tool | Ant is Java library for building code |
Jenkins automate the software deployment process | Maven stores project dependencies in pom.xml for build deployment process | helps in building code deployment using xml |
Jenkins provide Plugins for integration | does not provide plugin integration | does not provide plugin integration |
21) Give Environment variable names defined in Jenkins?
- $NODE_NAME
- $JOB_NAME
- $WORKSPACE
- $JOB_URL
- $BUILD_URL
22) What is flow control in Jenkins ?
Flow control is mechanism used by Scripted Pipeline structure for executing the Jenkinsfile from top to bottom approach
23) What is Agent Directive in Jenkins?
Agent Directive lets Jenkins know how to and where to execute the pipeline. The agent directive is provided at the top-level of the pipeline block.
24) How can we schedule a build in Jenkins?
The below given options can be sued for scheduling a build in Jenkins
- Schedule a Jenkins build using source code management commits
- Schedule a Jenkins build when all other build get completed
- Schedule a Jenkins build for a specified time as cron job
- Manually raise build request
25) What Does JENKINS_HOME directory contains ?
The JENKINS_HOME directory contains configurations, settings & logs
26) What step to perform when the pipeline first job is successful but second job failed ?
Restart the pipeline from the point where it failed by doing ‘restart from stage’
27) How to automate testing in Jenkins?
Automated tests can be executes using Selenium or maven. The test runs can be scheduled and every time test is executed by Jenkins, it send the report with test results
28) Name other continuous integration tools ?
- Bamboo
- ThoughtWorks
- Perforce
- Integrity