Jenkins is one such awesome continuous integration tool written in Java, that allows developers to integrate their changes into the project. Jenkins takes care of the rest of the process of build, deployment, testing, and analysis by automating it. The whole software development cycle now become a faster and smoother process.

We are sure that this will be useful for freshers and experienced professionals who want to start their careers with Jenkins.

1. What is Jenkins and why use it?

Jenkins is an open-source free automation tool used to build and test software projects. The tool makes it painless for developers to integrate changes to the project. Jenkins’ primary focus is to keep track of the version control system and initiate and monitor a build system if there are any changes. It keeps an eye on the entire process and provides reports and notifications to alert.

The following are the reasons to use Jenkins: 

  • It possesses an installer package for major operating systems.
  • Integrates individual projects for a larger purpose
  • To keep your team in sync
  • Troubleshoot and audit past jobs effortlessly
  • Provides accurate data support for project management

2. What are the Features of Jenkins?

  • Easy Installation & Configuration
  • Open-Source
  • Thriving Plugin Ecosystem
  • Easy Distribution
  • Provides a vast number of plugins
  • Provides pipeline support
  • Fast release cycles
  • Easy upgrades
  • Rapid release cycle.
  • Easy configuration setup.
  • Excellent community and documentation
  • Extensible with the use of third-party plugins.

3. What are the benefits of using Jenkins?

I will suggest you include the following benefits of Jenkins if you can recall any other benefit apart from the below-mentioned points you can include that as well.

  • At the integration stage, you can cache build failures.
  • For each change in the source code, you generate an automatic build report notification.
  • To notify developers about build report success or failure, Jenkins integrates with the LDAP mail server.
  • Achieves continuous integration of agile development and test-driven development.
  • With simple steps, you can automate the maven release project.
  • Easy tracking of bugs at an early stage in a development environment than production.

4. Tell me something about Continuous Integration, Continuous Delivery, Continuous Deployment, and Configuration Management?

  • 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, and 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
  • Configuration Management: Configuration management is a process for maintaining computer systems, servers, and software in a desired, consistent state. It’s a way to make sure that a system performs as it’s expected to as changes are made over time.
    • Code > Build > Integrate > release > deploy

5. What are the ways to install Jenkins?

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

6. Name some of the plugins in Jenkin?

Ans: Some of the important plugins in Jenkin include:

  • Maven 2 project
  • Amazon EC2
  • HTML publisher
  • Copy Artifact
  • Join
  • Green Balls
  • Git plugin
  • Multi job plugin
  • Test Results Analyzer
  • Metrics

7. What is the easiest way to install Jenkins?

  • Install Java Version 8
  • Install Apache Tomcat Version 9 
  • Download Jenkins war File
  • Deploy Jenkins war File
  • Install Suggested Plugins

8. What is the difference between Jenkins, Maven, and Ant?

JenkinsMavenAnt
Continuous Integration ToolBuild automation toolCommand Line/Java Library Tool.
Automates software development process through continuous integration and facilitates continuous delivery. Describes software dependencies and explains how the software is builtDrives build process
Supports version control tools like Git, AccuRev.Supports projects written in C#, Ruby.Supports projects written in C and C++.

9. Do you know any other continuous integration tools? How is Jenkins better than any of those?

There are many other CI tools, the prominent ones being –

  • TeamCity
  • Bamboo
  • Perforce
  • Circle CI
  • Go
  • ThoughtWorks
  • Integrity
  • Travis CI

There are many more. We cannot say if Jenkins is better than each because each has its own unique features. For example, TeamCity offers great .NET support but is complex and costly, Travis CI is free just like Jenkins and has good documentation too. Bamboo offers efficient and faster builds but is not completely free and so on.

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

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.

DevOps Interview Questions and Answers

Jenkins plays a great role because it helps in this integration by automating the build, test, and deployment process.

11. Give a simple use case/scenario to explain how Jenkins works.

  • Let us say a developer is working on some code changes and eventually commits them to the repository.
  • Jenkins server, which constantly checks for changes in the repository, detects the change and pulls the changes to trigger a build.
  • The build can fail, in which case the developer is informed with reports.
  • If the build passes, it is deployed onto the test server.
  • Once the testing is complete, a test report is generated and sent to the developers. This process continues till all the tests are successful, after which code is deployed to production.

12. What is a job in Jenkins?

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.

13. How can you create a job?

On the dashboard page, you can just select a ‘New Job’. When you create a job, you can choose options such as the SCM, triggers to control, the build script, and notifications.

14. What is meant by the 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 can be represented as –

15. What are the types of pipelines in Jenkins?

There are 3 types:

  1. CI CD pipeline (Continuous Integration Continuous Delivery)
  2. Scripted pipeline
  3. Declarative pipeline

16. How to create a backup and copy files in Jenkins?

The following steps will help you understand how to create a backup and copy files in Jenkins:

  • Periodically backup your JENKINS_HOME directory, which contains job configurations, slave node configurations, and all your build history.
  • To create a backup 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.

17. What could be the steps to move or copy Jenkins from one server to another?

There are multiple ways to move or copy Jenkins from one server to another:

  • You may move a job from one Jenkins installation to another just by copying the corresponding job directory.
  • You may make a copy of an already existing job by making a clone of the job directory with an uncommon name.
  • You may also just rename a current job by renaming a directory.

18. Differentiate between Bamboo and Jenkins?

S.noBambooJenkins
1Commercial toolOpen-source tool
2Dedicated development teamHuge global community
3Comparatively more user friendly Less user-friendly 
4Many built-in features and plugins are available in the Atlassian marketplace.Many plugins to perform different functions

19. What is the difference between Jenkins and Hudson?

S.noJenkinsHudson
1Jenkins is a free open-source Continuous Integration server.Hudson is an extensible Continuous Integration server
2Forked by HudsonContinuous Integration tool
3Used by companies like Netflix, Facebook, eBay, Instacart, LinkedIn, etc. Used by companies like Logo Yazilim, TableAir UAB and OptoSweden AB.
4Jenkins supports a lot of pluginsHudson supports a lesser number of plugins

20. How will you secure Jenkins?

The way I secure Jenkins is mentioned below if you have any other way to do it then mentioning that:

  • Make sure that the global security is on.
  • Check if Jenkins is integrated with my company’s user directory with an appropriate plugin.
  • Ensure that the matrix/Project matrix is enabled to fine-tune access.
  • Automate the process of setting rights/privileges in Jenkins with a custom version-controlled script.
  • Limit physical access to Jenkins data/folders.
  • Periodically run security audits on the same.

21. How does Jenkins authenticate users?

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 the LDAP server.

22. What are scripted pipelines?

Scripted pipelines are writing Jenkins pipelines as code in a traditional way. The scripted pipeline is defined within a ‘node’. The node is a part of the Jenkins architecture, where there are two types of a node, the agent or node will run the part of the workload of the jobs, and the master node will handle the configuration of the job.

23. 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 credentials, Azure secrets, etc. using commonly available plugins.

24. 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 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.

25. What are the two components (pre-requisites) that Jenkins is mainly integrated with?

Jenkins integrates with:

  1. Build tools/ Build working script like Maven script.
  2. Version control system/Accessible source code repository like Git repository.

Practical Questions


26. How to create a new build job in Jenkins?

The following steps will help you understand how to create a Jenkins job:

  • Step1: Logon to the Jenkins dashboard and click on the new item at the top left side of the dashboard.
  • Step2: Enter the item name and click on the freestyle project.
  • Step3: Enter the details of the project you want to test.
  • Step4: Enter your repository URL under source code management.
  • Step5: Under the build, click on add build step, and click on execute Windows batch command.
  • Step6: After entering the data, click on apply and save the project. 
  • Step7: Click on Build now button to build the source code.
  • Step8: To see the status of the build you run, click on the build number and click on the console output.

27. How can you start Jenkins manually?

Jenkins can be manually started by opening the Console/Command line and using the below commands:

  • Start Jenkins: jenkins.exe start
  • Stop Jenkins: jenkins.exe stop
  • Restart Jenkins: jenkins.exe restart

28. How to restart Jenkins manually?

To restart Jenkins manually, you can use any one of the following commands:

  • (jenkins_url)/safe restart – Allows all running jobs to complete. New jobs will remain in the queue to run after the restart is complete.
  • (jenkins_url)/restart – Forces a restart without waiting for builds to complete.

29. How can you deploy a custom build of a core plugin?

To deploy a custom build of a core plugin, you have to do the following:

  • 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.

30. What are declarative pipelines?

A declarative pipeline is a new feature in Jenkins that maintains the pipeline as a code and makes it easier to write and read. It is defined within a block labeled pipeline.

Syntax:

pipeline {
/* Declarative Pipeline */
}

Structure of the declarative pipeline:

  • any – It represents the whole pipeline will run on any available agent.
  • docker –  This is to run the pipeline in the Docker environment.
  • none – It indicates all the stages under the block will have to be declared with the agent separately.
  • label –  This is just a label for the Jenkins environment

31. 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.

Leave a Reply