DevOps Day 19 – Jenkins Hands-On Pipeline: Automating CI/CD with Jenkins

 Welcome to Day 19 of the DevOps Series πŸš€

In the previous session, we learned what CI/CD is and why it’s critical for modern software delivery.
Today, we move from theory to hands-on practice by learning how Jenkins pipelines automate the entire CI/CD workflow.

Jenkins is one of the most widely used CI/CD tools in the industry and acts as the backbone of many DevOps pipelines.


πŸ” What Is Jenkins?

Jenkins is an open-source automation server that helps DevOps engineers:

  • Build applications

  • Run automated tests

  • Perform code quality checks

  • Deploy applications automatically

In simple terms, Jenkins orchestrates your CI/CD process.


🧩 Jenkins in a CI/CD Flow

A typical Jenkins-based CI/CD workflow looks like this:

  1. Developer pushes code to GitHub

  2. Jenkins detects the code change

  3. Jenkins triggers a pipeline

  4. Pipeline runs:

    • Build

    • Test

    • Code quality checks

    • Deployment

  5. Application is deployed automatically

This removes manual effort and ensures fast and reliable delivery.


πŸ— Jenkins Pipeline Basics

A Jenkins Pipeline is a set of steps written as code that defines how your application is built, tested, and deployed.

Pipelines are written using a file called:

Jenkinsfile

This enables Pipeline as Code, which means:

  • Pipelines are version-controlled

  • Changes are traceable

  • Pipelines are reproducible


πŸ“Œ Types of Jenkins Pipelines

πŸ”Ή 1. Declarative Pipeline (Recommended)

  • Simple

  • Structured

  • Beginner friendly

πŸ”Ή 2. Scripted Pipeline

  • Flexible

  • Complex

  • Used for advanced logic

πŸ‘‰ In real-world DevOps, Declarative Pipelines are preferred.


πŸ“ Sample Declarative Jenkins Pipeline

Here’s a basic Jenkins pipeline example:

pipeline { agent any stages { stage('Checkout Code') { steps { git 'https://github.com/example/repo.git' } } stage('Build') { steps { echo 'Building the application' } } stage('Test') { steps { echo 'Running tests' } } stage('Deploy') { steps { echo 'Deploying application' } } } }

πŸ” What’s Happening Here?

  • agent any → Run on any available Jenkins worker

  • stages → Defines CI/CD phases

  • Each stage → Represents a pipeline step


⚙️ Common Jenkins CI/CD Commands

πŸ”Ή Start Jenkins

java -jar jenkins.war

πŸ”Ή Check Jenkins Version

java -jar jenkins.war --version

πŸ”Ή Restart Jenkins (Linux)

sudo systemctl restart jenkins

🌍 Real-Time Jenkins Use Cases

✅ 1. CI Pipeline

  • Compile code

  • Run unit tests

  • Generate reports

✅ 2. CD Pipeline

  • Deploy to Dev

  • Promote to Staging

  • Release to Production

✅ 3. Microservices Deployment

  • Jenkins triggers Docker builds

  • Pushes images to registry

  • Deploys to Kubernetes


⚠️ Challenges with Jenkins

While Jenkins is powerful, it has limitations:

  • Requires always-on servers

  • High maintenance for large systems

  • Scaling is complex

  • Plugin dependency issues

πŸ‘‰ This is why modern CI/CD tools like GitHub Actions are becoming popular (covered next).


πŸ”₯ Why Jenkins Is Still Important

Despite newer tools, Jenkins is:

  • Widely used in enterprises

  • Highly customizable

  • Tool-agnostic

  • Excellent for learning CI/CD fundamentals


✅ Summary



In DevOps Day 19, we learned:

  • What Jenkins is

  • How Jenkins fits into CI/CD

  • Jenkins Pipeline concepts

  • Jenkinsfile basics

  • Sample CI/CD pipeline

  • Real-world Jenkins use cases

Jenkins gives you hands-on exposure to real CI/CD workflows, making it an essential DevOps skill.

Comments

Popular posts from this blog

🧩 DevOps Day 1 — Fundamentals of DevOps

DevOps Day 23 — Multi-Stage Docker Builds & Distroless Images: Build Smaller, Safer Containers

πŸš€ DevOps Day 2 — Understanding the SDLC and the Role of DevOps Engineers