Jenkins Interview Ques
Jenkins Interview Ques
1. What is Jenkins?
Intermediate Questions
Trigger an API (POST) request to the target job URL with the required
data.
Trigger it manually from the Jenkins web application.
Trigger it using Jenkins CLI from the master/slave nodes.
Time-based Scheduled Triggers like a cron job.
Event-based Triggers like SCM Actions (Git Commit, Pull Requests),
WebHooks, etc.
Upstream/Downstream triggers by other Jenkins jobs.
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.
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.
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.
19. What happens when a Jenkins agent is offline and what is the
best practice in that situation?
When a job is tied to a specific agent on a specific node, the job can
only be run on that agent and no other agents can fulfill the job request.
If the target node is offline or all the agents on that particular node are
busy building other jobs, then the triggered job has to wait until the
node comes online or an agent from that node becomes available to
execute the triggered build request.
Even then if a job is waiting for more time for the nodes/agents, then it
is time to consider adding more nodes/agents.
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
Install the tool Plugin into the Jenkins instance, to include the global
tool into a list of global tools used by Jenkins.
Install the tool in the Jenkins instance or provide away (maybe a
command to download and) install the tool during runtime.
Go to Manage Jenkins -> Global Tools Configuration and Scroll
through the tool list and configure the global tool-specific
configurations.
Make use of the installed global Tool in your job/pipeline.
E.g.
#!/urs/bin/env groovy
@Library('[email protected]')_
SOURCE: If this points to a local file, that file will be installed. If this
is an URL, Jenkins downloads the URL and installs that as a plugin.
Otherwise, the name is assumed to be the short name of the plugin in
the existing update center (like "findbugs") and the plugin will be
installed from the update center.
-deploy: Deploy plugins right away without postponing them until the
reboot.
-name VAL: If specified, the plugin will be installed as this short name
(whereas normally the name is inferred from the source name
automatically).
-restart: Restart Jenkins upon successful installation.
Navigate to the Manage Jenkins > Manage Plugins page in the web UI.
Click on the Advanced tab.
Choose the .hpi file under the Upload Plugin section.
Upload the plugin file.
Restart the Jenkins instance
The master will need to be restarted before the plugin is loaded and
made available in the Jenkins environment.
32. How to download the Console log for a particular Jenkins build
programmatically?
E.g.
XML
JSON with JSONP support
Python
Ping thread is installed on both controller & agent; each side pings the
other and tries to detect the problem from their sides.
The ping thread time out is reported through java.util.logging. Besides,
the controller will also report this exception in the agent launch log.
Note that some agent launchers, most notably SSH agents, writes all
stdout/stderr outputs from the agent JVM into this same log file, so you
need to be careful.
Conclusion
Though these are not the complete possibilities of Jenkins, we tried to
cover some of the commonly asked interview questions on core Jenkins.
We also need to understand that the Jenkins Update Center is enriched
with thousands of useful plugins that enhance the supported
functionalities of Jenkins.
Intellipaat.
1. What is Jenkins?
Jenkins can be thought of as a free and open-source automation tool
that is used for continuous integration. It automates some of the
software development processes, such as building, testing, and
deployment. It can also be integrated with a large number of testing
and deployment technologies.
2. What is Jenkins used for?
Jenkins is used in the automation of some of the software
development processes. With Jenkins, one can continuously test
software projects so that developers can integrate the changes to
them. Jenkins facilitates continuous integration and delivery through
its built-in plugins.
1. Go to Manage Jenkins
2. Click on Create User
3. Enter all the details
4. Select Create User
6. What is Jenkinsfile?
A Jenkinsfile is essentially a text file containing the steps for running a
Jenkins Pipeline and is registered into the source control repository of
a project.
Find –httpPort=8080 and replace the port 8080 with the new port
number
The software prerequisites for installing Jenkins are that first we need
to install Java Development Kit. We also need to install the Jakarta
Enterprise Edition. Jenkins also comes with an embedded Jetty
Runtime that can be used if WebSphere or Tomcat is not available.
Get 50% Hike!
Master Most in Demand Skills Now !
Submit
Build
Test
Deploy
17. What are some of the useful plugins in Jenkins?
Some of the important plugins that are used with Jenkins are:
Git repository
Amazon EC2
HTML Publisher
JDK Parameter Plugin
Configuration Slicing Plugin
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.
Git
Subversion
CVS
Mercurial
After a successful build, the necessary files will get deployed to the
required container.