Jenkins For Automation Testing
βοΈ Jenkins Overview
1οΈβ£ What is Jenkins?
π Jenkins is an open-source automation server used to implement Continuous Integration (CI) and Continuous Delivery/Deployment (CD).
It automates:
Building projects
Running tests
Deploying applications
So instead of manually running builds/tests/deployments, Jenkins automates everything.
2οΈβ£ Why Jenkins came?
Before Jenkins (early 2000s), developers:
Built projects manually β time-consuming & error-prone.
Integrated code once in a while ("integration hell").
Deployment was manual, risky, and slow.
π Jenkins solved these by automating CI/CD pipelines β code is integrated, tested, and deployed automatically.
3οΈβ£ When Jenkins came?
Jenkins was created in 2004 by Kohsuke Kawaguchi at Sun Microsystems.
Initially called Hudson, renamed to Jenkins in 2011 (after Oracle dispute).
4οΈβ£ What problem does Jenkins solve?
Automation β no manual builds/tests/deploys.
Faster feedback β catch bugs early with CI.
Scalability β master-agent setup for distributed builds.
Consistency β same process across all environments.
Integration β works with Git, Maven, Selenium, Docker, Kubernetes, etc.
π In short: Jenkins automates software delivery pipeline end-to-end.
5οΈβ£ Where can we use Jenkins?
Automation Testing β run Selenium/TestNG/JUnit tests.
DevOps CI/CD β build β test β deploy pipelines.
Infrastructure as Code β integrate with Docker, Kubernetes, Terraform.
Monitoring β send reports via Email/Slack.
Enterprise Projects β distributed build and deployment pipelines.
6οΈβ£ When do we use Jenkins?
When you want continuous integration β automatically test code after each commit.
When you want continuous delivery/deployment β automatically deploy after successful tests.
When working with teams β so every developerβs code gets integrated and tested daily.
7οΈβ£ Prerequisite Knowledge for Jenkins
Before learning Jenkins, you should know:
Core Java (for Selenium/TestNG projects).
Maven/Gradle (build tools Jenkins integrates with).
Git/GitHub (source code management).
Basic Linux/Windows commands.
Automation Testing (Selenium/TestNG/JUnit).
(Optional) Docker, Kubernetes, Cloud (AWS/Azure/GCP) if you want to learn DevOps CI/CD.
β So in summary:
Maven automates builds & dependency management.
Jenkins automates the entire CI/CD pipeline (build β test β deploy).
Perfect π Letβs break down Jenkins components in detail with their roles.
π§© Jenkins Components & Their Work
1οΈβ£ Jenkins Server (Master/Controller)
The core of Jenkins.
Provides the web UI (
http://localhost:8080).Stores configuration, jobs, plugins.
Assigns work to agents (slaves).
Monitors builds and shows results.
π Think of it as the brain of Jenkins.
2οΈβ£ Jenkins Nodes (Agents/Slaves)
Machines that execute the jobs assigned by the Master.
Can be physical servers, VMs, or cloud instances.
Each node has labels (e.g., Windows, Linux, Docker) so jobs can run in the right environment.
π Master tells agents what to do, agents actually do the work.
3οΈβ£ Jenkins Jobs / Projects
A job is a task Jenkins performs (e.g., build, test, deploy).
Types:
Freestyle Project β simple jobs with manual config.
Maven Project β integrates with Maven lifecycle.
Pipeline Project β scripted with
Jenkinsfile.Multibranch Pipeline β CI/CD for multiple Git branches.
π Jobs are the heart of Jenkins automation.
4οΈβ£ Jenkins Pipelines
A way to define the CI/CD workflow as code (Jenkinsfile).
Two types:
Declarative Pipeline β simpler, structured.
Scripted Pipeline β full flexibility with Groovy scripting.
Consists of Stages (
Build,Test,Deploy) and Steps (commands inside stages).
π Pipelines = Automation as Code.
5οΈβ£ Jenkins Plugins
Jenkins is lightweight by default.
Plugins extend functionality:
Git plugin β SCM
Maven plugin β build automation
JUnit/TestNG plugin β test reports
Email/Slack plugin β notifications
Allure/Extent β test reporting
Docker/Kubernetes β DevOps integration
π Over 1800+ plugins available.
6οΈβ£ Jenkins Workspace
A directory on the agent machine where Jenkins checks out the project code and runs builds.
Example:
/var/lib/jenkins/workspace/MyProject/Contains source code, compiled classes, reports, and logs.
π Each job has its own workspace.
7οΈβ£ Jenkins Build Triggers
Defines when a job runs:
Manual Trigger β click "Build Now".
Poll SCM β check Git repo every X minutes.
Webhooks β trigger instantly when code is pushed.
Scheduled (Cron) β e.g., nightly builds.
Upstream/Downstream β trigger job chains.
π Triggers = automation entry point.
8οΈβ£ Jenkins Build Executors
Executors are slots on an agent that run jobs in parallel.
Example:
- 1 agent with 2 executors β can run 2 builds at the same time.
π Executors = multi-tasking power of Jenkins.
9οΈβ£ Jenkins Artifacts
The output of a Jenkins job (e.g., JAR, WAR, ZIP, reports).
Stored in
workspace/targetand can be archived in Jenkins.Used for deployments.
π Artifacts = deliverables.
π Jenkins Console Output (Logs)
Shows step-by-step execution logs of a job.
Useful for debugging build/test failures.
π Think of it as Jenkinsβ black box recorder.
1οΈβ£1οΈβ£ Jenkins Security & Credentials
Manages user authentication & authorization.
Stores secrets (API keys, passwords, SSH keys) securely.
Credentials are injected into jobs when required.
π Ensures builds are safe & secure.
1οΈβ£2οΈβ£ Jenkins Shared Libraries
Custom reusable Groovy code for pipelines.
Helps maintain DRY principle (Donβt Repeat Yourself).
π Useful for enterprise-level pipelines.
π― Summary (One-liner for each component)
Server (Master/Controller) β Brains of Jenkins.
Nodes (Agents/Slaves) β Workers that execute jobs.
Jobs/Projects β The actual tasks.
Pipelines β Workflow as code.
Plugins β Extend Jenkins features.
Workspace β Directory for build execution.
Triggers β When jobs run.
Executors β Parallel job slots.
Artifacts β Build outputs.
Console Output β Logs.
Security & Credentials β Safe access.
Shared Libraries β Reusable pipeline code.