Day 5: Jenkins Pipelines – Writing a Simple CI/CD Pipeline
Welcome to Day 5 of the 100 Days of DevOps & Cloud Challenge! 🎯
Today, we dive deep into Jenkins Pipelines, a core automation tool that powers Continuous Integration and Continuous Deployment (CI/CD).
Freestyle jobs might be familiar to you if you've used Jenkins before.
However, pipelines are essential for scaling DevOps effectively.
Jenkins, an open-source automation server, enables seamless automation of software build, test, and deployment processes, ensuring faster and more reliable software delivery.
In this post, we'll explore Jenkins Pipelines, understand their significance, and walk through the process of building one from scratch.
🔹 What is a Jenkins Pipeline?
A Jenkins Pipeline is a sequence of automated steps defining how code moves from development to production. Unlike traditional freestyle jobs, pipelines offer:
✅ Better version control – Written in code (Jenkinsfile), making it easy to manage. 📝
✅ Reproducibility – Reduces manual intervention, ensuring consistent builds, tests, and deployments.
✅ Flexibility – Supports parallel execution, distributed builds, and cloud integration.
✅ Scalability – A rich plugin ecosystem allows seamless tool integration.
By automating deployments, pipelines eliminate manual errors, boost productivity, and ensure efficient software delivery.
💡 Real-World Use Case
Imagine working at an e-commerce company where frequent feature deployments occur. Each release requires:
✅ Code testing
✅ Security checks
✅ Successful builds before going live
🚀 Jenkins Pipelines automate this process, ensuring every change is verified, built, tested, and deployed automatically.
This reduces deployment risks and accelerates software delivery.
🔹 Layman’s Example: The Pizza-Making Analogy 🍕
Think of a pizza-making process:
1️⃣ Order placed (Code pushed to GitHub)
2️⃣ Dough prepared (Code compiled)
3️⃣ Toppings & cheese added (Dependencies installed)
4️⃣ Pizza baked (Code tested & built)
5️⃣ Delivered hot & fresh! (Deployed to production)
Without automation, you'd have inconsistent pizzas and angry customers! 🍕🔥
🔹 Types of Jenkins Pipelines
Jenkins provides two types of pipelines:
1️⃣ Declarative Pipeline – Structured, user-friendly, and recommended for most cases ✅ 2️⃣ Scripted Pipeline – More flexible but complex (uses Groovy scripting) 🤯
For this post, we'll focus on the Declarative Pipeline since it's beginner-friendly.
🔹 Essential Jenkins Plugins for CI/CD
Jenkins thrives on plugins! Here’s a list of essential plugins across different CI/CD stages:
1️⃣ Core Plugins
Pipeline – Enables pipeline as code.
Git Plugin – Integrates with Git repositories.
Credentials Binding – Securely manages credentials.
2️⃣ Build & Compilation Plugins
Maven Plugin – Builds Java applications.
Gradle Plugin – Supports Gradle builds.
NodeJS Plugin – Essential for Node.js projects.
3️⃣ Testing & Code Quality Plugins
JUnit Plugin – Collects test reports.
SonarQube Scanner Plugin – Integrates SonarQube for static code analysis.
Checkstyle Plugin – Java code quality checks.
4️⃣ Deployment & Infrastructure Plugins
Docker Plugin – Builds & pushes Docker images.
Azure CLI Plugin – Allows executing Azure CLI commands in Jenkins.
AWS CLI Plugin – Supports AWS deployments via CLI commands.
Kubernetes Plugin – Deploys to Kubernetes.
Terraform Plugin – Manages infrastructure as code.
5️⃣ Notification & Monitoring Plugins
Slack Plugin – Sends notifications to Slack.
Email Extension Plugin – Customisable email notifications.
Prometheus Plugin – Exposes Jenkins metrics for monitoring.
🔹 Configuring Secrets in Jenkins Pipelines 🔒
Sensitive information such as API keys, passwords, and SSH keys should never be stored in a Jenkinsfile.
Instead, use Jenkins Credentials Store:
Steps to Add Credentials:
1️⃣ Go to Manage Jenkins > Manage Credentials
2️⃣ Choose Global Credentials (or a specific scope)
3️⃣ Click Add Credentials and select Secret Text, Username/Password, or SSH Key
4️⃣ Reference it in the pipeline:
🔹 Automatic Job Scheduling in Jenkins
Use cron syntax for scheduling jobs automatically:
Run every 15 minutes: H/15 * * * *
Run daily at midnight: 0 0 * * *
Run every Monday at 9 AM: 0 9 * * 1
Example in Pipeline:
🛠️ Hands-On: Writing a Simple CI/CD Pipeline
Step 1: Install Jenkins & Set Up GitHub Repo
🔹 Install Jenkins →Jenkins Installation Guide
🔹 Set up a GitHub repository for your project
🔹 Install Jenkins Git Plugin
Step 2: Create a Simple Node.js App
📌 app.js
Step 2: Define a Jenkinsfile (Declarative Pipeline)
📌 Jenkinsfile
Step 3: Configure Jenkins Job
1️⃣ Open Jenkins and create a New Item → Pipeline
2️⃣ Link it to your GitHub repository
3️⃣ Under pipeline settings, select Pipeline Script from SCM
4️⃣ Save & Click Build Now! 🚀
Your first CI/CD pipeline is live!
Key Takeaways
Jenkins Pipelines automate software delivery, ensuring faster and error-free deployments.
Use plugins and credential management for secure and efficient workflows.
Automate job execution with cron-based scheduling.
Implement a real-world example by integrating GitHub, Docker, and Jenkins.
With Jenkins Pipelines, software delivery becomes a highly efficient, automated process!
🔹 Summary: Why Jenkins Pipelines Matter?
✅ Automation saves time & reduces errors
✅ Faster deployments mean happier teams & customers
✅ Jenkins Pipelines enable smooth CI/CD workflows
🔜 Coming Next: Day 6 – Docker & Containerisation
🔥 Stay tuned for an in-depth dive into Docker!
💬 What’s your biggest challenge with Jenkins Pipelines? Let’s discuss in the comments! 👇
🔄 Reshare to help others master Jenkins & CI/CD! 🚀
📢 Follow Shruthi Chikkela for More!
🔔 Stay updated with daily DevOps insights, real-world use cases, and hands-on projects!
📩 Subscribe to My 100-Day DevOps Newsletter to never miss an update!
👉 Follow me on LinkedIn for more DevOps & Cloud content.
👉 Subscribe to the Newsletter for exclusive hands-on guides.
💡 Let’s build, automate, and innovate together! 💻🔥
#100DaysOfDevOps #CI/CD #Jenkins #Cloud #DevOps #Learnwithshruthi #CareerByteCode #Linkedin
Senior Manager – Cloud Solutions Architect | AD & Endpoint Modernization | Digital Workplace Leader| Digital Transformation | Future Technology Director | Finops | PMP | Cybersecurity ISC2 Certified | DEVOPS | Automation
5moAbsolutely fantastic insights on Jenkins Pipelines! 🌟
DevOps & Cloud Engineer, Scalable Infrastructure, Containerization & Orchestration, Automate Deployment & Delivery, Infrastructure as Code | AWS, GCP & Azure | Linux, Docker, K8s, Terrafrom, CICD tools,Continuous Learner
5morecently i have read a article saying jenkins is less demand nd github actions leading now a days . what’s ur view ?