Practice
Resources
Contests
Online IDE
New
Free Mock
Events New Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
logo
Events
Attend free live masterclass hosted by top tech professionals
New
Scaler
Explore Offerings by SCALER
exit-intent-icon

Download Interview guide PDF

Before you leave, take this Jenkins Interview Questions interview guide with you.
Get a Free Personalized Career Roadmap
Answer 4 simple questions about you and get a path to a lucrative career
expand-icon Expand in New Tab
/ Interview Guides / Jenkins Interview Questions

Jenkins Interview Questions

Last Updated: Dec 21, 2024

Download PDF


Your requested download is ready!
Click here to download.
Certificate included
About the Speaker
What will you Learn?
Register Now

In this article, we will discuss the important aspects of using Jenkins in the Software SDLC process with a special focus on Jenkins interview questions. This article will start with an Introduction to Continuous Integration and Continuous Deployment and the role Jenkins plays as an automation tool in the SDLC process, with some in-depth discussions on Jenkins’ capabilities & how-to’s focusing more on the Interview Questions on Jenkins across - Basic, Intermediate & Advanced levels.

With the latest advancements in the world of Continuous Integration and Continuous Deployment for the Software Development Life-Cycle (SDLC) process, it is possible to deliver the developed software much faster to the end-users than it was with the traditional approaches. Even though there are so many tools to enable the development teams to deliver the Software - fast and continuous - the set of open source tools available to achieve this will have its edge.

One such excellent, open-source tool enabling continuous & fast-paced software development in this Dev-Ops era is - Jenkins - an Open-source software serving the needs of the software teams from - Developing, Building, Testing, Deploying and monitoring - the software.

Jenkins can be used for a large number of software-based automation that runs on-premise or on-cloud. It has several benefits over the other available automation software and the best of those is the fact that Jenkins is completely open-source and highly extensible with its plugin-based architecture.

Jenkins is -

  • Easy to install.
  • Easy to configure.
  • Pluggable with custom Plugins & hence highly extensible.
  • More than everything, Jenkins is inherently distributed in nature and hence can support any scale by distributing the workloads across nodes & agents.

Jenkins Interview Questions For Freshers

1. What is Jenkins?

Jenkins is a self-contained, open-source automation server that can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software. Jenkins can be installed through native system packages, Docker, or even run standalone by any machine with a Java Runtime Environment (JRE) installed.

Create a free personalised study plan Create a FREE custom study plan
Get into your dream companies with expert guidance
Get into your dream companies with expert..
Real-Life Problems
Prep for Target Roles
Custom Plan Duration
Flexible Plans

2. Tell me something about Continuous Integration, Continuous Delivery, and Continuous Deployment?

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, 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

Based on the level of automation, the above three paradigms can be better represented as below -

CI/CD and Continuous Deployment

3. What are the common use cases Jenkins is used for?

Jenkins being open-source automation can be used for any kind of software-based automation. Some of the common use-cases include but not limited to -

  • Software build jobs
  • Sanity/Smoke/CI/Regression test jobs
  • Web/Data Scraping related jobs
  • Code coverage measurement jobs
  • General-purpose automation
  • Reverse Engineering jobs
  • Key Decoding jobs & many other jobs where software automation will be applicable.
You can download a PDF version of Jenkins Interview Questions.

Download PDF


Your requested download is ready!
Click here to download.

4. What are the ways to install Jenkins?

Jenkins can be installed using -

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

For more detailed installation instructions refer official documentation

5. What is a Jenkins job?

A Job/Project is the fundamental unit of a logical work (like a software build, an automation task, test execution, etc) using the Jenkins automation server and other required plugins, configurations & infrastructures.

Jobs can be of different types like - a freestyle project, a multi-configuration project, a pipeline project, a multi-branch project, etc.

Learn via our Video Courses

6. What is a Jenkins Pipeline?

Jenkins Pipeline

The pipeline is a special type of Jenkins job - simply a sequence of steps controlled by a defined logic - which Orchestrates long-running activities that can span across multiple build agents. It is suitable for building pipelines (formerly known as workflows) and/or organizing complex activities that cannot be easily achieved using a freestyle job.

Understand how to create your first pipeline here

7. What are the types of Jenkins pipelines?

Jenkins Pipelines can be either - a Declarative pipeline or a Scripted Pipeline. Declarative pipeline makes use of numerous, generic, predefined build steps/stages (i.e. code snippets) to build our job according to our build/automation needs whereas, with Scripted pipelines, the steps/stages can be custom-defined & used using a groovy syntax which provides better control & fine-tuned execution levels.

Advance your career with   Mock Assessments Refine your coding skills with Mock Assessments
Real-world coding challenges for top company interviews
Real-world coding challenges for top companies
Real-Life Problems
Detailed reports

8. Explain Jenkins Multibranch Pipeline?

Jenkins Multibranch Pipeline

It is a pipeline job that can be configured to Create a set of Pipeline projects according to the detected branches in one SCM repository. This can be used to configure pipelines for all branches of a single repository e.g. if we maintain different branches (i.e. production code branches) for different configurations like locales, currencies, countries, etc.

9. How do you store credentials in Jenkins securely?

Credentials can be stored securely in Jenkins using the Credentials plugin, which stores different types of credentials like - Username with a password, SSH username with the private key, AWS Credentials, Jenkins Build Token, Secret File/Text, X509 & other certificates, Vault related credentials securely with proper encryption & decryption as and when required.

10. How can we stop a scheduled job from being executed temporarily?

Disable the job from the job details page to temporarily stop all scheduled executions & other factors/events from triggering the job and enable it back to resume the job schedules/triggers. If a job is not required permanently, we can delete the job from the jobs list view page.

Intermediate Questions

1. What are the ways to trigger a Jenkins Job/Pipeline?

There are many ways we can trigger a job in Jenkins. Some of the common ways are as below -

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

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

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

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

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

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

7. How Jenkins jobs can be Triggered/Stopped/Controlled programmatically?

Jenkins Remote Access API can be used to do things like -

  • Retrieving information about jobs, views, nodes, builds, etc. from Jenkins for programmatic consumption.
  • Trigger a build (both parameterized & non-parameterized), stop/abort a build, enable/disable a Job, group/remove jobs into/from views, etc.
  • Create/copy/modify/delete jobs.

and many other programming language-specific functionalities. It has wrappers for main programming languages like - Python, Ruby & Java. It can be triggered via CURL as below -

Jobs without parameters

Simply an HTTP POST on JENKINS_URL/job/JOBNAME/build.

Jobs with parameters

Simple example - sending "String Parameters":

curl JENKINS_URL/job/JOB_NAME/buildWithParameters  --user USER:TOKEN --data id=123 --data verbosity=high

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

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

As a result, a triggered job may sometimes wait indefinitely without knowing that the target node is offline. So, it is always the best practice to tie the jobs to a group of nodes & agents, referred to with a 'Label'. Once a job is tied to a Label, instead of a specific node/agent, any of the nodes/agents falling under the label can fulfill a build request, when a job is triggered. This way we can reduce the overall turn-around time of the builds.

Even then if a job is waiting for more time for the nodes/agents, then it is time to consider adding more nodes/agents.

10. What is the Blue Ocean?

Blue Ocean is the redefined user experience for Jenkins. Designed from the ground up for Jenkins Pipeline, it is still compatible with freestyle jobs, Blue Ocean reduces clutter and increases clarity. Blue Ocean’s main features include -

  • Sophisticated visualizations of continuous delivery (CD) Pipelines, allowing for fast and intuitive comprehension of your Pipeline’s status.
  • Pipeline editor - makes the creation of Pipelines approachable by guiding the user through an intuitive and visual process to create a Pipeline.
  • Personalization to suit the role-based needs of each member of the team.
  • Pinpoint precision when intervention is needed and/or issues arise. Blue Ocean shows where in the pipeline attention is needed, facilitating exception handling and increasing productivity.
  • Native integration for branch and pull requests, enables maximum developer productivity when collaborating on code with others in GitHub, Bitbucket, etc.

Conventional UI - Job Details Page

Conventional UI Jenkins

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

Jenkins Interview Questions for Automation Testers

1. What are post-build actions in Jenkins relevant to QA automation? How do you structure the post block?

The post block contains the steps that run after the pipeline execution finishes. It is commonly used for things like sending notifications, cleaning workspaces, publishing reports, or handling success and failure conditions separately. Each condition in the post block serves a specific purpose and runs based on the final state of the build.

A well-structured post block for a QA automation pipeline looks like this:

post {
    always {
        junit '**/*.xml'
        jacoco execPattern: '**/jacoco.exec'
        cleanWs()
    }
    success {
        archiveArtifacts artifacts: 'target/*.jar'
        emailext subject: "Build PASSED: ${JOB_NAME} #${BUILD_NUMBER}",
                 to: 'qa-team@company.com'
    }
    failure {
        emailext subject: "Build FAILED: ${JOB_NAME} #${BUILD_NUMBER}",
                 attachmentsPattern: '**/surefire-reports/*.txt',
                 to: 'qa-team@company.com'
    }
    unstable {
        slackSend channel: '#qa-alerts',
                  color: 'warning',
                  message: "Tests failing: ${JOB_NAME} ${BUILD_URL}"
    }
}

The always block runs regardless of outcome and is the right place for actions that must never be skipped. JUnit result publishing, coverage reporting via JaCoCo for Java or Istanbul for JavaScript, and workspace cleanup all belong here. Artifacts are only archived on success because storing build outputs from a broken build serves no purpose and wastes storage. The failure block attaches surefire report text files to the notification email, so the first thing the team sees is the actual failure detail rather than having to navigate to Jenkins separately. The unstable block handles the distinct case where the build compiled and ran successfully, but tests failed, routing those alerts to a dedicated Slack channel rather than mixing them with hard build failures.

One important practice for teams dealing with notification fatigue is only alerting on state changes rather than every build. If the previous build also failed, sending another failure email adds noise without adding value. This is handled by comparing the current build result against the previous one before sending any notification:

failure {
    script {
        if (currentBuild.previousBuild?.result != 'FAILURE') {
            emailext subject: "Build FAILED: ${JOB_NAME}",
                     to: 'qa-team@company.com'
        }
    }
}

This way, the team gets notified when something breaks and when it recovers, without being flooded with repeated alerts for a failure that is already known and being worked on.

2. How do you configure Jenkins to automatically trigger test runs on every pull request?

Automatically running tests on every pull request requires Jenkins to be notified when a PR is opened or updated, and then report the result back to GitHub so it can be enforced as a required check before merging.

The recommended approach is to use a Multibranch Pipeline with the GitHub Branch Source plugin. Once configured, Jenkins automatically discovers all branches and open pull requests in the repository, creating a pipeline job for each one and running the Jenkinsfile on every new commit. A GitHub webhook configured for push and pull_request events is what triggers these builds in real time rather than relying on polling. The GitHub Branch Source plugin also handles posting the build result back to the PR as a GitHub Checks status, so the PR shows a passing or failing check directly without any additional configuration.

The older alternative is the GitHub Pull Request Builder plugin, which achieves the same outcome but requires more manual setup and lacks the native Checks API integration that the Branch Source plugin provides out of the box.

In team-based workflows, keeping PR builds stable usually comes down to two key practices. First, requiring the Jenkins build to pass as a required status check in GitHub branch protection rules means a PR with failing tests simply cannot be merged, enforcing quality at the repository level rather than relying on developers to check the build manually. Second, when a developer pushes multiple commits to the same PR in quick succession, older builds become irrelevant and waste executor capacity. Setting disableConcurrentBuilds(abortPrevious: true) in the pipeline options automatically cancels the running build when a newer commit arrives:

options {
    disableConcurrentBuilds(abortPrevious: true)
}

Draft pull requests should also be excluded from triggering builds since they are works in progress and not ready for review or testing. The GitHub Branch Source plugin supports this through its PR discovery strategy configuration, where draft PRs can be ignored entirely until they are marked ready for review.

3. How do you generate and publish Allure reports in a Jenkins pipeline? What is the CSP issue?

Allure produces richer test reports than the standard JUnit plugin, offering a timeline view of test execution, failure category analysis, and retry attempt tracking across builds. Setting it up requires two things: an adapter in the test framework to generate the raw results, and the Allure Jenkins plugin to collect and render them.

On the test framework side, the adapter depends on what the project uses. Java projects add allure-junit5 or allure-cucumberjvm as a dependency. Python projects add allure-pytest. Each adapter writes JSON results into an allure-results directory during the test run, which the Jenkins plugin then picks up. Publishing is added to the post block, so reports are generated on every build regardless of outcome:

post {
    always {
        allure results: [[path: 'allure-results']]
    }
}

The CSP Issue

The most common blocker when setting up Allure in Jenkins is the Content Security Policy header that Jenkins sets on all served content by default. This header blocks the JavaScript that Allure reports depend on to render their interactive views, resulting in a blank or broken report page despite the plugin running successfully.

The fix is clearing the CSP header via the Jenkins Script Console:

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

This setting does not persist across Jenkins restarts, so for a permanent fix, it needs to be added to the Jenkins JVM startup arguments. An alternative approach that avoids touching the CSP entirely is using the HTML Publisher plugin with relaxed settings to serve the Allure report, which sidesteps the header restriction without modifying Jenkins security configuration.

4. How do you publish JUnit test results in a Jenkins pipeline? What metrics does it surface?

The JUnit plugin is the standard way to surface test results in Jenkins. It reads XML reports generated by the test framework after a build and presents them as structured metrics directly on the build page. Since test results should always be published regardless of whether the build passed or failed, the junit step belongs in the always condition of the post block:

post {
    always {
        junit 'target/surefire-reports/**/*.xml'
    }
}

Once the XML is parsed, Jenkins surfaces four categories of metrics. Pass, fail, and skip counts give an immediate summary of the test run. Per-test execution times identify slow tests that are adding unnecessary time to the pipeline. The test trend graph tracks these counts across builds over time, making it easy to spot whether the failure rate is growing or shrinking. Flaky test detection flags tests that pass in some builds and fail in others without any code changes, which are often more damaging to pipeline reliability than consistently failing tests because they erode trust in the results.

The JUnit plugin is not limited to Java projects. TestNG generates JUnit-compatible XML out of the box. Python projects using pytest produce the same format with the pytest-junit plugin. NUnit covers .NET test suites. This makes the same junit step and the same metrics available regardless of the language or framework the project uses.

Also note that there are some distinct differences between an UNSTABLE build and a FAILED build in Jenkins. When test failures are detected in the XML report, Jenkins marks the build as UNSTABLE, shown in yellow. A FAILURE in red means the build process itself broke, such as a compilation error or a script that exited with a non-zero code. The two states are deliberately separate so that a test regression does not get conflated with a broken build.

5. How do you integrate Selenium tests into a Jenkins pipeline? What is the setup for headless execution?

Selenium tests require a browser to run, which creates a challenge in a headless CI environment where no display is available. The cleanest solution is using Docker to provide a pre-configured browser environment directly as the pipeline agent, eliminating any manual browser installation or display configuration on the Jenkins agent itself:

groovy
pipeline {
    agent {
        docker { image 'selenium/standalone-chrome:latest' }
    }
    stages {
        stage('Run Selenium Tests') {
            steps {
                sh 'mvn test -Dwebdriver.chrome.headless=true'
            }
        }
    }
}

The selenium/standalone-chrome image comes with Chrome and ChromeDriver pre-installed and configured for headless execution. For Python-based test suites, the equivalent step would be pytest tests/ --html=report.html, which runs the tests and generates an HTML report in the same pass.

For teams running large test suites that need to execute in parallel, Selenium Grid is the more appropriate setup. A hub and node architecture is brought up in a pre-build stage using docker-compose, and tests are distributed across the available nodes automatically. This cuts execution time significantly when the test suite has grown too large for a single browser instance.

On test failure, capturing a screenshot at the point of failure is essential for debugging. This is handled by attaching an EventFiringWebDriver with a screenshotOnFailure listener, which automatically captures and saves a screenshot whenever a test fails. Those screenshots are then archived as build artifacts so they are accessible directly from the Jenkins build page without needing to re-run the failure locally.

Test results are published using the Allure plugin, which produces a rich interactive report with timeline views, failure categorization, and retry tracking that goes significantly beyond what the standard JUnit report provides.

Advanced Interview Questions

1. Can we monitor Jenkins using common Observability tools?

Common monitoring platforms like DataDog, Prometheus, JavaMelody & few others - have their corresponding Jenkins plugin, which when configured, sends Metrics to the corresponding Monitoring platform, which can then be Observed with the latest tools & technologies. The same can be configured with Alarms & Notifications for immediate attention when something goes wrong.

2. What is a Ping Thread in Jenkins and how it works?

Jenkins installs "ping thread" on every remote connection, such as Controller/Agent connections, regardless of its transport mechanism (such as SSH, JNLP, etc.). The lower level of the Jenkins Remoting Protocol is a message-oriented protocol, and a ping thread periodically sends a ping message that the receiving end will reply to. The ping thread measures the time it takes for the reply to arrive, and if it’s taking excessive time (currently 4 minutes and configurable), then it assumes that the connection was lost and initiates the formal close down.

This is to avoid an infinite hang, as some of the failure modes in the network cannot be detected otherwise. The timeout is also set to a long enough value so that a temporary surge in the load or a long garbage collection pause will not trip off the close-down.

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.

Before appearing for an interview, make sure to install a Jenkins Server on any of the supported platforms - either locally or on the cloud, install the most common plugins (suggested by Jenkins itself & other commonly used plugins). Try creating & building a normal freestyle project with Git or any other SCM integration plugin and try to execute some code from the connected Git Repository.

Also, try creating a pipeline project with JenkinsFile and a global shared Jenkins library and build the job successfully. This will help us learn how Jenkins actually works with some hands-on issues.

Additional Resources

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

4. How is continuous integration achieved using Jenkins?

Continuous integration is a process where a developer’s code changes are constantly integrated into the main code and the same will be tested automatically and the results of the tests will decide whether the change is ready for deployment. In this process -

  • Developer Makes a change - commit/pull_request - in feature/dev branch
  • Source Control Management system generates appropriate events
  • SCM Specific Jenkins Plugins like Git/SVN will detect those events from the configured repositories and these events will be used to Trigger - build/dependent/test - jobs on Jenkins
  • After the Test/Dependent jobs are completed, the change/patch will be labeled according to the status of the test job
  • Based on the Status (i.e. readiness of a change to be merged with the main branch), the Continuous Delivery or Continuous Deployment strategy/tool will take it forward.

5. 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/**/*'

6. What is In-process Script Approval and how it works?

Jenkins, and several plugins, allow users to execute Groovy scripts in Jenkins. To protect Jenkins from the execution of malicious scripts, these plugins execute user-provided scripts in a Groovy Sandbox that limits what internal APIs are accessible.

This protection is provided by the Script Security plugin. As soon as an unsafe method is used in any of the scripts, the "In-process Script Approval" action should appear in "Manage Jenkins" to allow Administrators to make a decision about which unsafe methods, if any, should be allowed in the Jenkins environment.

This in-process script approval inherently improves the security of the overall Jenkins ecosystem.

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

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

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

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

11. How to do Global Tools Configuration in Jenkins?

Global Tools are tools that need to be installed outside the Jenkins environment and need to be controlled from within the Jenkins environment. Hence it needs its corresponding Jenkins plugin as well. Steps to using a Global Tool generally include -

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

12. How to create & use a Shared Library in Jenkins?

Basic requirements for a Jenkins shared library to be used in a Pipeline Code are -

  • A Repository with pipeline shared library code in SCM.
  • An appropriate SCM Plugin configuration for the Jenkins instance.
  • Global Shared Library should be configured in Jenkins Global configuration.
  • Include the Shared Library in the Pipeline Code and use the methods defined in the Jenkins Shared Library.

E.g.

#!/urs/bin/env groovy
@Library('fs_jenkins_shared_library@v2.0.7')_

13. How to install a Custom Jenkins Plugin or a Version of Plugin Not available in Jenkins Update Center?

Generally, it is the best practice to use the latest version of a plugin. But there are ways to install custom plugins or outdated versions of a published plugin. Jenkins Plugins are exported using a .hpi file and the same can be installed in multiple ways -

Using the Jenkins CLI

java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin SOURCE ... [-deploy] [-name VAL] [-restart]

The above command Installs a plugin either from a file, an URL or from the update center.

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

Advanced Installation - via - Web UI

Assuming a .hpi file has been downloaded, a logged-in Jenkins administrator may upload the file from within the web UI:

  • 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

Advanced Installation - via - On the master

Assuming a .hpi file has been explicitly downloaded by a systems administrator, the administrator can manually place the .hpi file in a specific location on the file system.

Copy the downloaded .hpi file into the JENKINS_HOME/plugins directory on the Jenkins controller (for example, on Debian systems JENKINS_HOME is generally /var/lib/jenkins).

The master will need to be restarted before the plugin is loaded and made available in the Jenkins environment.

14. How to download the Console log for a particular Jenkins build programmatically?

Using the Jenkins CLI - console - command

java -jar jenkins-cli.jar console JOB [BUILD] [-f] [-n N]

Produces the console output of a specific build to stdout, as if you are doing 'cat build.log'

  • JOB: Name of the job
  • BUILD: Build number or permalink to point to the build. Defaults to the last build
  • -f: If the build is in progress, append console output as it comes, like tail -f
  • -n N: Display the last N lines.

E.g.

ssh -l <ssh_username> -p <port_no> <Jenkins_URL> console <JOB_NAME>

15. What is Jenkins Remote Access API?

Jenkins provides remote access API to most of its functionalities (though some functionalities are programming language-dependent). Currently, it comes in three flavors -

  • XML
  • JSON with JSONP support
  • Python

Remote access API is offered in a REST-like style. That is, there is no single entry point for all features, and instead, they are available under the ".../api/" URL where the "..." portion is the data that it acts on.

For example, if your Jenkins installation sits at interviewbit.com, visiting /api/ will show just the top-level API features available – primarily a listing of the configured jobs for this Jenkins instance.

Or if we want to access information about a particular build, e.g. https://ci.jenkins.io/job/Infra/job/jenkins.io/job/master/lastSuccessfulBuild/, then go to https://ci.jenkins.io/job/Infra/job/jenkins.io/job/master/lastSuccessfulBuild/api/ and you’ll see the list of functionalities for that build.

Jenkins Interview Questions for Experienced (Scenario-Based)

1. A Jenkins pipeline stage intermittently fails with "no space left on device." How do you diagnose and permanently fix it?

Intermittent space errors on a Jenkins agent are usually caused by old workspace data piling up over time. The first thing thay you should do is log into the agent and check which filesystem is running out of space.

Diagnosis starts with the agent itself. Running df -h confirms which filesystem is full and how much space remains on each mounted partition. Once the full partition is identified, the next step is finding which workspace directories are responsible. Running these two commands against the workspace root gives a clear picture of which jobs are consuming the most space and whether any single workspace has grown beyond a reasonable size:

find /var/jenkins/workspace -maxdepth 1 -size +500M -type d
du -sh /var/jenkins/workspace/*

Once the culprits are identified, the fix involves three changes applied together in the pipeline configuration. Adding cleanWs() in the post block ensures the workspace is wiped after every build. Configuring logRotator caps how many builds and artifacts Jenkins retains. Setting disableConcurrentBuilds() prevents multiple instances of the same job from running simultaneously and stacking up separate workspaces. Together, these three options cover the most common causes of runaway disk usage:

pipeline {
    options {
        buildDiscarder(logRotator(numToKeepStr: '10'))
        disableConcurrentBuilds()
    }
    post {
        always {
            cleanWs()
        }
    }
}

For a permanent solution, migrating to ephemeral Kubernetes pod agents removes the problem at the source. The pod and its workspace are destroyed the moment a build completes, so disk accumulation never gets a chance to occur. For artifact-heavy builds that genuinely need persistent storage, a dedicated agent with a larger disk and strict retention policies is the more suitable long-term approach.

2. How would you migrate 50+ freestyle Jenkins jobs to declarative pipelines at scale?

Okay, so migrating 50+ freestyle Jenkins is not quite possible to do manually. Which means that you’ll have to go step-by-step and make audits, build reusable components, and lastly roll out gradually with a fallback in place.

This is what you should do for such questions -

Phase 1 - Audit

The starting point is exporting all job configurations to understand what you are working with. The Jenkins API makes this straightforward:

GET /api/json?depth=2

This returns the full configuration of every job. From there, jobs are categorized by their build steps, SCM configuration, and notification patterns. Most large Jenkins instances have far less variety than they appear to at first glance, and this audit typically reveals that the majority of jobs follow three or four common patterns.

Phase 2 - Shared Library

Before writing a single Jenkinsfile, the common stages identified in the audit are encapsulated into a shared library. The vars/ directory holds global pipeline steps for checkout, build, test, and notify that every job can call. This ensures that common logic lives in one place and does not get duplicated across fifty Jenkinsfiles.

Phase 3 -Template

One representative job from each category is converted into a Jenkinsfile template and validated against a staging Jenkins instance before any production jobs are touched. This is where edge cases surface without any real impact.

Phase 4 - Bulk Generation

With validated templates in place, Jenkins Job Builder YAML or Job DSL scripts are used to generate Jenkinsfiles and multibranch pipeline jobs at scale. Rather than writing each Jenkinsfile by hand, the generation scripts take job-specific variables as input and produce consistent, standardized pipeline definitions across all jobs.

Phase 5 - Rollout

Migration is rolled out in cohorts by team rather than all at once. The old freestyle job is kept as a fallback for two weeks alongside the new pipeline, giving teams time to validate behavior before the freestyle version is retired. This window also catches any environment-specific issues that did not surface in staging.

3. Your Jenkins controller is under heavy load with 100+ developers. How do you scale Jenkins?

When Jenkins starts struggling under high traffic, your solution will be based on checking where the bottleneck is and how far the team is willing to scale the setup, since this can be quite a burdensome challenge for the DevOps team. Here are some possible solutions -

1. Short-Term - The fastest wins come from the agent layer. Increasing executor counts on existing agents immediately allows more concurrent builds without any infrastructure changes. For workloads that are consistently heavy, adding dedicated agents with specific labels keeps resource-intensive builds from competing with lighter ones:

agent { label 'docker' }
agent { label 'maven' }
agent { label 'npm' }

Labeling agents this way ensures Docker builds, Maven builds, and Node builds each run on agents sized and configured for their specific requirements rather than sharing a general-purpose pool.

2. Medium-Term - The Kubernetes plugin is the most impactful medium-term change. Instead of maintaining a fixed pool of always-on agents, pod agents spin up on demand when a build starts and are destroyed the moment it finishes. This brings idle cost to zero and makes the agent pool effectively elastic, expanding automatically under load and contracting when the build slows down. Alongside this, organizing jobs into folders using the Folders plugin with separate credential scopes per team reduces the blast radius of credential misuse and makes access control significantly easier to manage. Thin Backup paired with S3 ensures the controller configuration is backed up periodically, so recovery after a failure is fast.

3. Long-Term - Once the setup grows to support large engineering teams, the Jenkins controller itself can become a risk since everything depends on it staying healthy. At that stage, teams usually start looking into high-availability setups to avoid a single point of failure. It’s also a good time to reassess whether Jenkins still works for every workflow. In many cases, smaller teams with straightforward CI pipelines can move to tools like GitHub Actions or GitLab CI/CD, which help reduce load on Jenkins without adding more infrastructure.

4. How do you manage secrets and credentials securely in a Jenkinsfile? What are the anti-patterns?

The correct approach to managing secrets in Jenkins starts with the Jenkins Credentials Store, which keeps credentials out of the codebase entirely. Secrets stored there are referenced by a credential ID inside the pipeline using withCredentials, which injects them as masked environment variables that never appear in plain text in build logs:

withCredentials([usernamePassword(
    credentialsId: 'db-credentials',
    usernameVariable: 'USER',
    passwordVariable: 'PASS'
)]) {
    sh 'deploy.sh --user $USER --pass $PASS'
}

Jenkins masks the values of USER and PASS automatically in the build output so they cannot be read from logs, even if a build fails midway through.

For teams that already use HashiCorp Vault for secrets management, the Jenkins Vault plugin integrates directly with Vault's secret engine, pulling credentials dynamically at build time rather than storing them in Jenkins at all. This is the stronger option for production environments where secret rotation and fine-grained access policies matter.

Anti-patterns to avoid:

  1. Hardcoding credentials directly in the Jenkinsfile. Since Jenkinsfiles live in source control, any committed secret is immediately exposed to everyone with repository access and permanently visible in Git history.
  2. Using plain text to build parameters for secrets. String parameters passed at build time appear in plain text in the build history and are not masked anywhere in the Jenkins UI.
  3. Using echo to print secret variables. Log masking in Jenkins is not perfect and can be bypassed in certain output formats, so echoing secret variables should never be treated as safe, even for debugging purposes.

Credential usage across pipelines can be audited through the Credentials Binding audit log, which tracks which jobs are accessing which credentials. When a secret is compromised, it should be rotated immediately in the Credentials Store, and any affected Vault paths should be revoked, since the credential ID reference in the Jenkinsfile stays the same and no pipeline changes are needed.

5. A build fails only on the main branch, not on feature branches. What is your investigation process?

Branch-specific failures usually happen because something differs between the main branch and the feature branch. It could be the environment, pipeline configuration, dependencies, or even the pipeline logic itself. The debugging process is mostly about narrowing those differences down one by one until the actual cause shows up.

The first step is using Jenkins' built-in Replay feature to re-run the failed main branch build with a modified Jenkinsfile without committing any changes. This lets you test hypotheses about the pipeline logic quickly without polluting the branch history.

The second step is comparing environment variables between branches. The env.BRANCH_NAME variable is a common source of branch-specific behavior because when clauses use it to conditionally enable or skip stages. A stage that only runs on main could be failing while feature branches skip it entirely, making the failure appear branch-specific when it is actually stage-specific.

when { branch 'main' }

Third, check the agent label assigned to the main branch pipeline. Main branch jobs are sometimes configured to run on a specific agent that feature branch jobs do not use, and that agent may have a misconfigured environment, missing dependencies, or different tool versions installed.

Fourth, inspect whether any credentials or environment variables are configured exclusively for main branch builds. A missing or expired credential that only gets injected on main will cause failures that never surface on feature branches at all.

Fifth, check for race conditions caused by concurrent main branch builds competing for the same resource, whether that is a shared agent, a deployment environment, or an external service with rate limits.

Finally, review recent Jenkinsfile changes committed directly to main. Feature branches may be running an older version of the Jenkinsfile that predates the change that introduced the failure, which makes the comparison between branches misleading.

6. What is Jenkins Configuration as Code (JCasC)? How does it enable GitOps for Jenkins?

Jenkins Configuration as Code, or JCasC, is a plugin where the entire Jenkins system configuration is written in YAML files and stored in version control. Everything that would otherwise be configured manually through the Jenkins UI, including global settings, plugin configuration, node definitions, credentials, security realm, and authorization strategies, is expressed declaratively in a YAML file that Jenkins reads and applies on startup.

A typical JCasC file looks like this:

jenkins:
  systemMessage: "Jenkins configured via JCasC"
  securityRealm:
    local:
      allowsSignup: false
  authorizationStrategy:
    loggedInUsersCanDoAnything:
      allowAnonymousRead: false
  nodes:
    - permanent:
        name: "build-agent-01"
        remoteFS: "/home/jenkins"
        labelString: "docker maven"

The configuration is applied by setting the casc.jenkins.config.path system property to point at the YAML file, or through the UI via Manage Jenkins > Configuration as Code. Any change to the file is picked up on the next reload without restarting Jenkins.

This is what enables a genuine GitOps workflow for Jenkins. Every configuration change goes through a pull request, gets reviewed, and is merged into the repository before it ever reaches the Jenkins instance. The Git history becomes a complete audit trail of every infrastructure change, and rolling back a misconfiguration is as straightforward as reverting a commit. If the Jenkins instance is lost entirely, it can be reconstructed from the YAML file in minutes.

Combining JCasC with Job DSL or multibranch pipeline auto-discovery takes this further. Job DSL scripts define the jobs themselves as code, and multibranch pipelines discover Jenkinsfiles automatically from repositories. Together with JCasC, this achieves a fully code-defined Jenkins instance where no manual UI configuration is required at any level.

7. How would you implement a blue-green deployment pipeline in Jenkins?

A blue-green deployment keeps two identical production environments running at all times, with only one serving live traffic at any given moment. The pipeline deploys to the inactive environment, validates it, and then switches traffic over, keeping the previous environment intact as an immediate rollback target.

The pipeline moves through seven stages in sequence.

Stage 1 - Build

The first stage builds the application artifact, packages it into a Docker image tagged with the build number, and pushes it to the container registry. Tagging with BUILD_NUMBER ensures every image is uniquely identifiable and traceable back to the exact pipeline run that produced it:

stage('Build') {
    steps {
        sh 'docker build -t myapp:${BUILD_NUMBER} .'
        sh 'docker push myregistry/myapp:${BUILD_NUMBER}'
    }
}

Stage 2 - Determine Inactive Slot

Before deploying anything, the pipeline needs to know which slot is currently inactive. Rather than hardcoding blue or green, the pipeline queries the load balancer API and stores the result as an environment variable that all subsequent stages can reference:

stage('Determine Inactive Slot') {
    steps {
        script {
            env.INACTIVE_SLOT = sh(
                script: 'curl -s https://lb-api/active-slot | jq -r .inactive',
                returnStdout: true
            ).trim()
        }
    }
}

Stage 3 - Deploy to Inactive Slot

With the inactive slot identified, the Kubernetes Deployment is updated with the new image. The rollout status command blocks the pipeline until all pods are fully healthy, ensuring the next stage never runs against a partially deployed environment:

stage('Deploy') {
    steps {
        sh "kubectl set image deployment/${env.INACTIVE_SLOT} app=myregistry/myapp:${BUILD_NUMBER}"
        sh "kubectl rollout status deployment/${env.INACTIVE_SLOT}"
    }
}

Stage 4 - Smoke Tests

Smoke tests run directly against the inactive slot endpoint to validate application behavior before any live traffic reaches it. This is the last safety check before the traffic switch, so tests here should cover the most critical user-facing functionality.

Stage 5: Approval Gate

Rather than switching traffic automatically, an input step pauses the pipeline and requires explicit human sign-off. The timeout wrapper ensures the pipeline does not hang indefinitely if no one responds within the defined window:

stage('Approve Traffic Switch') {
    steps {
        timeout(time: 30, unit: 'MINUTES') {
            input message: "Switch traffic to ${env.INACTIVE_SLOT}?", ok: "Switch"
        }
    }
}

Stage 6 - Switch Traffic

Once approved, the Kubernetes Service selector is updated to point at the newly deployed slot, moving all live traffic to it immediately.

Stage 7 - Monitor and Decommission

Automated health checks run for five minutes against the now-active slot. If all checks pass, the previously active slot is decommissioned. If any check fails, traffic is switched back to the previous slot automatically, completing the rollback without manual intervention. Infrastructure state across both slots is managed through Terraform steps within the pipeline, keeping environment definitions consistent and version controlled throughout the process.

Jenkins Pipeline Interview Questions

1. What are Jenkins shared libraries? How do you structure, version, and test them?

When the same pipeline logic appears across multiple Jenkinsfiles, that is a signal to move it into a shared library. A shared library is a separate Git repository containing reusable Groovy code that any pipeline in the Jenkins instance can import, keeping individual Jenkinsfiles clean and ensuring common logic like build, test, and notification steps is maintained in one place.

The repository follows a defined three-folder structure. The vars/ directory holds global pipeline steps written as Groovy files with a call() method, which pipelines invoke directly as if they were built-in steps. The src/ directory holds standard Groovy classes for more complex logic that needs a proper object-oriented structure. The resources/ directory holds non-code files like configuration templates that pipeline code can load at runtime using libraryResource().

The library is registered once under Manage Jenkins > System > Global Pipeline Libraries. Once registered, any pipeline imports it using the @Library annotation and can pin to a specific version using a Git tag:

@Library('my-lib@v1.2.0') _
pipeline {
    agent any
    stages {
        stage('Build') {
            steps { buildApp() }
        }
    }
}

Versioning is managed through Git tags, meaning library changes go through the same review process as application code, and breaking changes can be introduced in a new version without affecting pipelines pinned to older ones. Testing is handled using the Jenkins Pipeline Unit framework, which lets you unit test shared library Groovy code locally without needing a running Jenkins instance.

2. What is the difference between Declarative and Scripted Pipelines? Which should you use and why?

Both pipeline types use a Jenkinsfile stored in source control, but Declarative Pipelines use a predefined syntax with built-in pipeline sections, while Scripted Pipelines are written with Groovy code and give developers more direct control over pipeline execution.

Declarative pipelines use a structured DSL wrapped inside a pipeline {} block with predefined directives like agent, stages, steps, post, environment, parameters, and triggers. The structure is validated before execution begins, which means syntax errors are caught upfront rather than mid-run. This makes Declarative pipelines easier to read, easier to onboard new team members onto, and the right default choice for the vast majority of CI/CD workflows.

Scripted pipelines use a node {} block and are essentially Groovy code with no structural enforcement. This gives maximum flexibility to express complex logic, but that flexibility comes at the cost of maintainability. Without a defined structure, Scripted pipelines can become difficult to reason about as they grow, and there is no upfront validation to catch errors before execution starts.

! But remember - always start with Declarative. !

The only reason to drop into Scripted is when Declarative genuinely cannot express the logic required, such as complex conditional branching or dynamic stage generation that changes based on runtime conditions.

When a Declarative pipeline needs a small piece of Groovy logic that does not fit naturally into its structure, the script {} block provides an escape hatch without abandoning the Declarative format entirely:

groovy
pipeline {
    agent any
    stages {
        stage('Example') {
            steps {
                script {
                    def buildEnv = env.BRANCH_NAME == 'main' ? 'production' : 'staging'
                    echo "Deploying to ${buildEnv}"
                }
            }
        }
    }
}

This keeps the pipeline Declarative at the top level while allowing Groovy expressions where they are genuinely needed, without rewriting the entire pipeline in Scripted format.

3. Explain the complete structure of a Jenkinsfile. What is each directive used for?

A Jenkinsfile is a file that stores the CI/CD pipeline configuration in code form. In Declarative Pipelines, the file follows a fixed structure where each section controls a specific part of the pipeline, such as agents, stages, environment variables, or post-build actions. A complete Jenkinsfile typically looks like this:

pipeline {
    agent { docker { image 'node:18' } }
    environment {
        APP_ENV = 'production'
        DB_PASS = credentials('db-password')
    }
    parameters {
        string(name: 'VERSION', defaultValue: '1.0', description: 'Build version')
        booleanParam(name: 'RUN_TESTS', defaultValue: true, description: 'Run test suite?')
        choice(name: 'REGION', choices: ['us-east', 'eu-west'], description: 'Deploy region')
    }
    options {
        buildDiscarder(logRotator(numToKeepStr: '10'))
        timeout(time: 30, unit: 'MINUTES')
        disableConcurrentBuilds()
        retry(2)
    }
    triggers {
        cron('H 8 * * 1-5')
        pollSCM('H/5 * * * *')
    }
    stages {
        stage('Build') {
            steps {
                sh 'npm install && npm run build'
            }
        }
        stage('Test') {
            parallel {
                stage('Unit Tests') {
                    steps { sh 'npm run test:unit' }
                }
                stage('Integration Tests') {
                    steps { sh 'npm run test:integration' }
                }
            }
        }
        stage('Deploy') {
            when {
                branch 'main'
                environment name: 'APP_ENV', value: 'production'
            }
            steps {
                sh './deploy.sh'
            }
        }
    }
    post {
        always   { cleanWs() }
        success  { slackSend message: "Build passed: ${JOB_NAME}" }
        failure  { emailext subject: "Build failed: ${JOB_NAME}" }
        unstable { slackSend message: "Tests failing: ${BUILD_URL}" }
    }
}

Each directive in this structure has a distinct responsibility.

The pipeline is the mandatory top-level block that wraps the entire Declarative pipeline definition. agent defines where the pipeline runs, whether that is any available agent, a specific labeled agent, or a Docker container with a defined image.

environment declares key-value pairs that are injected as environment variables across all stages, and it can pull values directly from the Jenkins Credentials Store using credentials(). parameters defines inputs that can be supplied at build time, supporting string, boolean, choice, and password types.

options controls build-level settings like how many builds to retain, whether concurrent runs are allowed, how long a build can run before timing out, and how many times to retry on failure. triggers automates when builds start, either on a cron schedule, by polling the SCM for changes, or when an upstream job completes.

stages holds the sequential build phases, each defined as a named stage block containing steps.

parallel runs multiple stages concurrently inside a single parent stage, which is useful for running independent test suites simultaneously.

when controls whether a stage executes at all based on conditions like branch name, environment variable values, or custom Groovy expressions. post defines actions that run after the pipeline completes, with condition blocks for always, success, failure, unstable, and cleanup covering every possible outcome.

4. How do you run parallel stages in Jenkins? What is the failFast option?

Running stages in parallel reduces total pipeline execution time by running independent workloads simultaneously. In a Declarative pipeline, parallel stages are defined inside a parent stage using the parallel block, with each named stage inside it running concurrently on its own executor:

groovy
stage('Parallel Testing') {
    failFast true
    parallel {
        stage('Unit Tests') {
            steps { sh 'mvn test' }
        }
        stage('Integration Tests') {
            steps { sh 'mvn verify' }
        }
        stage('Lint') {
            steps { sh 'npm run lint' }
        }
    }
}

By default, all three stages run to completion regardless of whether any of them fail. Setting failFast: true changes this so that as soon as one branch fails, Jenkins aborts all remaining parallel branches immediately, which is useful when continuing other stages serves no purpose after a failure.

Each parallel branch can be assigned its own agent or Docker image when different stages have different environment requirements. When parallel stages need to share build artifacts produced by an earlier stage, stash saves files at the end of one stage and unstash restores them at the start of another, making the artifacts available across branches without needing a shared filesystem.

5. How do you use the input step in Jenkins pipelines? What are production deployment gate patterns?

The input step pauses a pipeline at a defined point and waits for a human to take action before proceeding. This makes it the standard mechanism for introducing manual approval gates into deployment pipelines, particularly before changes reach production.

The basic form presents a message and a confirmation button. Adding a submitter restriction limits who can approve, ensuring only designated team members or roles can authorize a production deployment:

stage('Approve') {
    steps {
        input(
            message: 'Deploy to production?',
            submitter: 'ops-team,release-manager',
            ok: 'Deploy'
        )
    }
}

When the approval decision needs to carry additional context, the input step accepts parameters that the approver fills in at the time of approval. A common use case is letting the approver choose the target deployment region rather than hardcoding it:

stage('Approve') {
    steps {
        script {
            def params = input(
                message: 'Select deployment target',
                parameters: [
                    choice(choices: ['us-east', 'eu-west'], name: 'REGION')
                ]
            )
            env.DEPLOY_REGION = params
        }
    }
}

In production pipelines, three practices make approval gates reliable. First, always wrap input in a timeout block. Without it, a pipeline waiting for approval holds an executor and blocks other builds indefinitely. Second, restrict approval gates to protected branches using a when clause so feature branch builds are never held up waiting for production approvals. Third, Jenkins automatically logs which user approved the input and at what time, providing an audit trail for every production deployment without any additional configuration needed.

stage('Approve') {
    when { branch 'main' }
    steps {
        timeout(time: 30, unit: 'MINUTES') {
            input(
                message: 'Deploy to production?',
                submitter: 'ops-team,release-manager',
                ok: 'Deploy'
            )
        }
    }
}

6. How do you integrate Docker into a Jenkins Declarative Pipeline?

Docker integrates with Jenkins pipelines in two distinct ways, depending on whether Docker is being used as the build environment or as the thing being built.

The first pattern is using Docker as the agent. Instead of running pipeline steps on a bare Jenkins agent, the entire stage runs inside a container that is spun up at the start and destroyed at the end. This guarantees a clean, consistent environment for every build without any dependency management on the agent itself:

groovy
pipeline {
    agent {
        docker {
            image 'node:18-alpine'
            args '-u root'
        }
    }
    stages {
        stage('Build') {
            steps {
                sh 'npm install && npm run build'
            }
        }
    }
}

The second pattern is building and pushing Docker images as part of the pipeline steps. Here, the agent is a standard Jenkins agent with Docker installed, and the pipeline uses docker.withRegistry to authenticate against a registry before pushing the built image:

groovy
stage('Build and Push') {
    steps {
        script {
            docker.withRegistry('https://registry.hub.docker.com', 'dockerhub-creds') {
                docker.build("myapp:${BUILD_NUMBER}").push()
            }
        }
    }
}

docker.withRegistry handles authentication using a credential ID from the Jenkins Credentials Store, so registry credentials never appear in the Jenkinsfile itself.

For teams running Docker at scale, the Kubernetes plugin is the more practical alternative. Rather than mounting the Docker socket on a shared agent, it uses podTemplate to define ephemeral pod agents with multiple containers, each serving a specific purpose within the same build. This avoids the security implications of Docker socket mounting, where a container with access to the host Docker socket can effectively control the host machine, and replaces always-on agents with pods that are created on demand and deleted immediately after the build completes.

Jenkins MCQ

1.

How can we stop a Jenkins job from being executed temporarily?

2.

Can we install a custom plugin into my Jenkins instance?

3.

Can we use Jenkins for Unit Testing?

4.

Which of the following plugin facilitates Git SCM connectivity?

5.

What are the languages supported by Jenkins?

6.

Which of the following SCM tool does Jenkins support?

7.

What is the minimum requirement for using Jenkins?

8.

Which of the following is a type of Jenkins Job?

9.

Can we integrate Microsoft Active Directory for Login with Jenkins?  
 

10.

Which scope of credentials is good for Jenkins’ core functionalities?

Excel at your interview with Masterclasses Know More
Certificate included
What will you Learn?
Free Mock Assessment
Fill up the details for personalised experience.
Phone Number *
OTP will be sent to this number for verification
+91 *
+91
Change Number
Graduation Year *
Graduation Year *
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
*Enter the expected year of graduation if you're student
Current Employer
Company Name
College you graduated from
College/University Name
Job Title
Job Title
Engineering Leadership
Software Development Engineer (Backend)
Software Development Engineer (Frontend)
Software Development Engineer (Full Stack)
Data Scientist
Android Engineer
iOS Engineer
Devops Engineer
Support Engineer
Research Engineer
Engineering Intern
QA Engineer
Co-founder
SDET
Product Manager
Product Designer
Backend Architect
Program Manager
Release Engineer
Security Leadership
Database Administrator
Data Analyst
Data Engineer
Non Coder
Other
Please verify your phone number
Edit
Resend OTP
By clicking on Start Test, I agree to be contacted by Scaler in the future.
Already have an account? Log in
Free Mock Assessment
Instructions from Interviewbit
Start Test