Skip to main content

Command Palette

Search for a command to run...

Jenkins For Automation Testing

Updated
β€’5 min readβ€’View as Markdown

βš™οΈ 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:

  1. Core Java (for Selenium/TestNG projects).

  2. Maven/Gradle (build tools Jenkins integrates with).

  3. Git/GitHub (source code management).

  4. Basic Linux/Windows commands.

  5. Automation Testing (Selenium/TestNG/JUnit).

  6. (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/target and 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.

More from this blog

Shreenibas Samal's blog

49 posts