Jenkins Interview Questions for Freshers/Jenkins Interview Questions and Answers for Freshers & Experienced

How can a job configuration be reset to an earlier version/state?

From the Job details page, we can use Job Config History to - See diff, Review & Revert the Job configs from the history of changes we have made to a particular job. This will be super useful when a job is misconfigured by someone by mistake, it can be reviewed and reverted easily to any of its earlier states.

Default Environment Variables by Jenkins & How to introduce custom environment variables?

Jenkins provides several environment variables by default like - BRANCH_NAME, BUILD_NUMBER, BUILD_TAG, WORKSPACE, etc.

How code coverage is measured/tracked using Jenkins in a CI environment?

Using language-specific code coverage plugins like JaCoCo, CodeCov, etc or generic tools/plugins like Sonarqube which will add the code coverage data to builds with some minor tweaks in the code and the same can be displayed as a graph in Jenkins.

What is the use of JENKINS HOME directory?

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

How can we share information between different build steps or stages in a Jenkins Job?

Every build step or stage will be running in its process and hence sharing information between two different build steps is not so direct. We can use either a File, a Database Entry, an Environment Variable, etc. to share info from one build step to another or a post-build action.

How to configure inclusions & exclusions in Artifacts Archival?

Artifact archival takes in a pattern for matching target files. Similarly, it also takes in a pattern (ANT build system pattern for matching files) for exclusion as well which will be ignored while selecting the files for archival.

For e.g.
archiveArtifacts artifacts: 'output/*.txt', excludes: 'output/specific_file.txt'

The above command will archive all the text files from the output folder except specific_file.txt

What is Artifact Archival & how to do it in Pipelines?

Artifacts are the exportable/storable/archivable results of a specific job build. This can be configured using a plugin called - Copy artifact Plugin. Based on the configured pattern, the files/directories matching the configured patterns will be archived for a Jenkins build, which can be used for future references. In the pipeline, it can be configured as follows -

archiveArtifacts artifacts: 'output/**/*'

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

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

What is the Jenkins User Content service?

Jenkins has a mechanism known as "User Content", where administrators can place files inside the $JENKINS_HOME/userContent folder and these files are served from yourhost/jenkins/userContent.

This can be thought of as a mini HTTP server to serve images, stylesheets, and other static resources that you can use from various description fields inside Jenkins.

How to get the Jenkins version programmatically in Jobs/Pipelines or nodes other than master?

To check the version of Jenkins, load the top-level page or any top-level Remote Access API path like the '.../api/*' page and then check for the 'X-Jenkins' response header.

This contains the version number of Jenkins, like "1.404". This is also a good way to check if an URL is a Jenkins URL.

Have you run automated tests on Jenkins? How is it done?

Yes, this can be done easily. Automated tests can be run through tools like Selenium or maven. Developers can schedule the test runs. Jenkins displays the test results and sends a report to the developers.

What is a Jenkins Shared Library and how it is useful?

As an organization starts using more and more pipeline jobs, there is a chance for more and more code being duplicated in every pipeline job, since a part of the build/automation processes will be the same for most of the jobs. In such a situation, every other new upcoming job should also duplicate the same piece of code. To avoid duplications, the Jenkins project brought in the concept of Shared Libraries, to code - DRY - Don't Repeat Yourself.

Shared libraries are a set of code that can be common for more than one pipeline job and can be maintained separately. Such libraries improve the maintenance, modularity & readability of the pipeline code. And it also speeds up the automation for new jobs.

What are the Scopes of Jenkins Credentials?

Jenkins credentials can be of one of the two scopes - Global & System

Global - the credential will be usable across all the jobs configured in the Jenkins instance (i.e. for all jobs). This is more suited for user Jobs (i.e. for the freestyle, pipeline, or other jobs) to authenticate itself with target services/infrastructures to accomplish the purpose of the job)

System - This is a special scope that will allow the Jenkins itself (i.e. the core Jenkins functionalities & some installed plugins) to authenticate itself to external services/infrastructures to perform some defined tasks. E.g. sending emails, etc.

How Jenkins knows when to execute a Scheduled job/pipeline and how it is triggered?

Jenkins master will have the cron entries set up for the jobs as per the scheduled Job's configurations. As and when the time for a particular job comes, it commands agents (based on the configuration of the job) to execute the job with required configurations.

What is Jenkins Build Cause?

Build Cause is a text attribute that represents what made a job's build to be triggered, say it could be a Jenkins User (from UI), Timer for Scheduled jobs, Upstream jobs for a job which was triggered by upstream job, etc. This is mainly used to identify the nature of the builds - be it nightly, manual, automated, etc.

Do you know about cloud computing? How can Jenkins fit into a cloud computing environment? Explain with an example.

Let us take the example of AWS cloud service. Cloud computing services use the CI/CD model so that they can push their work to the customers and constantly receive feedback. Jenkins is used to automating the CI/CD pipelines. For example, a lot of Jenkins plugins are available for many of the AWS services like Amazon EC2 and ECS.

Explain the terms Agent, post-section, Jenkinsfile

Agent: It is directive to tell Jenkins to execute the pipeline in a particular manner and order.

Post-section: If we have to add some notification and to perform other tasks at the end of a pipeline, post-section will definitely run at the end of every pipeline’s execution.

Jenkinsfile: 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 a CI/CD pipeline?

CI/CD Pipeline or Continuous Integration/ Continuous Delivery is referred to as the DevOps approach's backbone. The pipeline is responsible for building codes, running tests, and deploying new software versions.

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.

State some of the advantages of using Jenkins.

Here are some of the most important advantages of Jenkins:

* We will get an automated build report every time a change is made to the source code.
* We will be able to achieve continuous integration with agile methodology principles.
* We can automate the maven release project with a few simple steps.
* Bugs can be easily tracked at an early development stage.

How to take a backup of your Jenkins build jobs?

Within the XML configuration, each Jenkins build is stored. When this folder is copied, the configuration of all the build jobs that are managed by the Jenkins master is backed up. If we can perform a Jenkins Git integration, then it is good. When we copy the contents of the folder, we will see that the build jobs described in the folder will be restored when the Jenkins server is started the next time.

How to configure and use third-party tools in Jenkins?

These are the steps used for working with a third-party tool 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.
* We can then use the plug-in from the Jenkins build job.

How to make sure that your project build does not break in Jenkins?

You need to follow the below-mentioned steps to make sure that the Project build does not break:

1. Clean and successful installation of Jenkins on your local machine with all unit tests.
2. All code changes are reflected successfully.
3. Checking for repository synchronization to make sure that all the differences and changes related to config and other settings are saved in the repository.

Which Environmental Directives are used in Jenkins?

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

What you do when you see a broken build for your project in Jenkins?

I will open the console output for the broken build and try to see if any file changes were missed. If I am unable to find the issue that way, then I will clean and update my local workspace to replicate the problem on my local and try to solve it.

If using SVN polling or scheduling a building job in Jenkins, what syntax is used?

Cron syntax is used for building a job in Jenkins. Cron syntax is represented by five asterisks, each separated by a space. The syntax is as follows – [minutes] [hours] [day of the month] [month] [day of the week]. For example, if you want to set up a Cron for every Monday at 11.59 pm, it would be 59 11 * * 1.

How will you secure Jenkins?

The way I secure Jenkins is mentioned below if you have any other way to do it than mention 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 custom version controlled script.
* Limit physical access to Jenkins data/folders.
* Periodically run security audits on the same.

What are Parameters in Jenkins?

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

How will you define Post in Jenkins?

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 is Maven? What is the benefit of integrating Maven with Jenkins?

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.

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

Jenkin is mainly integrated with two components

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

Explain how you can set up Jenkins job?

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.

Explain how you can clone a Git repository via Jenkins?

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.

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

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.

How do you install Jenkins?

Follow the steps mentioned below to install Jenkins:

* Install Java
* Install Apache Tomcat Server
* Download Jenkins war Fil

Name the types of pipelines in Jenkins?

There are 3 types:

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

Which CI Tools are used in Jenkin?

Jenkins supported the following CI tools:

1. Jenkins
2. GitLab CI
3. Travis CI
4. CircleCI
5. Codeship
6. Go CD
7. TeamCity
8. Bamboo

Explain the Jenkins pipeline?

A pipeline is a set of interconnected jobs that are executed one after another in a predetermined order. Jenkins pipelines have several modules that can be used to combine and incorporate continuous deployment pipelines. Code is used to convey the directions to be followed.

Jenkins pipeline (or just “Pipeline”) is a collection of plugins that help you set up and use continuous distribution pipelines in Jenkins. A continuous distribution pipeline is an integrated representation of the product delivery process, from source code to consumers and customers.

What is Jenkinsfile?

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

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

To deploy a custom field of a core plugin, you have to do following things

* 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

Which command is used to start Jenkins?

You can follow the below-mentioned steps to start Jenkins:

1. Open Command Prompt
2. From the Command Prompt browse the directory where Jenkins. war resides
3. Run the command given below:

D:>Java –jar Jenkins.war

Explain Jenkins’ working in a simple use-case?

Let’s assume a developer is operating on a code and contributes it to the repository.

* Jenkins server scans for adjustments in the repository detects the code and pulls it to start a build.
* If the build malfunctions, the results are sent to the developer to make changes.
* If it succeeds, the build is deployed to a test server.
* A test report is produced and submitted to the developer when the testing is completed. This method is * repeated until the code passes all the checks, after which it is deployed to output.

Explain what Groovy means?

Jenkins uses a domain-specific language (DSL) called “Groovy” inside a Pipeline Project (read plugin), which will describe a new pipeline as just a script. That single script may articulate a flow that would typically take several “standard” Jenkins jobs chained around.

Groovy will work in conjunction with Java, and the two languages’ syntaxes are very close. While writing Groovy, when you forget the grammar, you can write in Java syntax. Groovy may be used as one of the Java platform’s scripting languages. Groovy scripts could be named from inside Java, reducing the amount of time spent on Java development.

What is the difference between Hudson and Jenkins?

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 are the pre-requisites for using Jenkins?

The answer to this is pretty straightforward. 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?

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

What is the requirement for using Jenkins?

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 what is continuous integration?

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.

Define the process of Jenkins.

First, a developer commits the code to the source code repository. Meanwhile, the Jenkins server checks the repository at regular intervals for changes.

Soon after a commit occurs, the Jenkins server detects the changes that have occurred in the source code repository. Jenkins will pull those changes and will start preparing a new build.

If the build fails, then the concerned team will be notified.

If the build is successful, then Jenkins deploys the build in the test server.

After testing, Jenkins generates feedback and then notifies the developers about the build and test results.

It will continue to check the source code repository for changes made in the source code and the whole process keeps on repeating.

What is Jenkins?

Jenkins is an open-source automation tool written in Java with plugins built for Continuous Integration purposes. Jenkins is used to build and test your software projects continuously making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build. It also allows you to continuously deliver your software by integrating with a large number of testing and deployment technologies.

R4R Team
R4R provides Jenkins Freshers questions and answers (Jenkins Interview Questions and Answers) .The questions on website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,Jenkins Interview Questions for Freshers,Jenkins Freshers & Experienced Interview Questions and Answers,Jenkins Objetive choice questions and answers,Jenkins Multiple choice questions and answers,Jenkins objective, Jenkins questions , Jenkins answers,Jenkins MCQs questions and answers Java, C ,C++, ASP, C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for Jenkins fresher interview questions ,Jenkins Experienced interview questions,Jenkins fresher interview questions and answers ,Jenkins Experienced interview questions and answers,tricky Jenkins queries for interview pdf,complex Jenkins for practice with answers,Jenkins for practice with answers You can search job and get offer latters by studing .learn in easy ways .