Jenkins Interview Questions & Answers

Jenkins is an open-source automation tool used for Continuous Integration (CI) and Continuous Delivery (CD). It helps automate build, test, and deployment processes.

CI is a development practice where developers frequently merge code into a shared repository, and automated builds/tests are triggered to detect issues early.

CD is the process of automatically preparing code changes for release to production after successful testing.

  • Automates test execution
  • Supports scheduled execution
  • Integrates with Selenium, Maven, Git, TestNG
  • Generates reports
  • Helps in CI/CD pipeline
  • Open-source and free
  • Large plugin support
  • Easy integration with tools
  • Platform independent
  • Supports distributed builds

A Jenkins job/project is a task or automated process configured in Jenkins, such as build execution or test execution.

  • Freestyle Project
  • Pipeline Project
  • Multibranch Pipeline
  • Maven Project

A Jenkins Pipeline is a sequence of automated steps written as code to build, test, and deploy applications.

Declarative PipelineScripted Pipeline
Simple syntaxComplex and flexible
Easy to maintainRequires Groovy scripting
Structured formatMore customization

A Jenkinsfile is a text file containing pipeline script written in Groovy that defines CI/CD workflow.

Example:

pipeline {
   agent any
   stages {
       stage('Build') {
           steps {
               echo 'Build Started'
           }
       }
   }
}

Maven is a build management tool used to compile code, manage dependencies, and run test cases in Jenkins.

Steps:

  1. Create Selenium Maven project
  2. Push code to GitHub
  3. Configure Jenkins job
  4. Add Git repository URL
  5. Add Maven commands like: clean test
  6. Execute build
  • Git Plugin
  • Maven Integration Plugin
  • TestNG Plugin
  • HTML Report Plugin
  • Allure Report Plugin
  • Pipeline Plugin

Using Build Triggers with CRON expressions.

Example:

H 10 * * *

Runs daily at 10 AM.

SCM stands for Source Code Management. Jenkins integrates with tools like Git and SVN to fetch source code.

  • Master: Controls Jenkins
  • Agent/Node: Executes jobs assigned by master

Jenkins can trigger tests:

  • On code commit
  • On schedule
  • Manually
  • After another job completion
  • Add TestNG plugin
  • Configure post-build action
  • Provide TestNG result XML path

Example:

test-output/testng-results.xml

Blue Ocean is a modern UI for Jenkins that provides better visualization for pipelines.

  • Build status becomes FAILED
  • Notification can be sent
  • Logs help identify issues
  • Developers/testers fix the issue and rerun build

By enabling:
This project is parameterized

Parameters:

  • String Parameter
  • Choice Parameter
  • Boolean Parameter
  • Build: Compiling and packaging code
  • Release: Deploying application to users/environment

Using:

  • Email
  • Slack
  • Microsoft Teams
  • Telegram plugins

Jenkins connects with GitHub or Git repositories to pull latest code automatically for execution.

  1. Developer commits code to Git
  2. Jenkins detects changes
  3. Build starts automatically
  4. Test cases execute
  5. Reports are generated
  6. Deployment happens if build passes

Workspace is the directory where Jenkins stores project files and executes builds.

Poll SCM checks source code repository periodically for changes.

Example:

H/5 * * * *

Checks every 5 minutes.

Use browser options.

Example:

ChromeOptions options = new ChromeOptions();
options.addArguments("--headless");

Actions performed after build completion like:

  • Publishing reports
  • Sending emails
  • Archiving artifacts

Artifacts are files generated after build execution like:

  • JAR files
  • Reports
  • Logs
  • Screenshots