Day 26: Jenkins Declarative Pipeline Task – Completed! 🎉
DevOps | Cloud Practitioner | AWS | GIT | Kubernetes | Terraform | ArgoCD | Gitlab
🚀 Today’s Task: Exploring Jenkins Declarative Pipeline – the backbone of modern CI/CD practices.
What is a Pipeline?
A Pipeline in Jenkins is a collection of steps or jobs, arranged sequentially to automate building, testing, and deploying your application. With Jenkins, pipelines come in two flavors:
Declarative: Modern, structured, and easier to read.
Scripted: Groovy-based and more flexible but harder to manage.
Why Pipelines are Important?
Pipeline as Code: Written as a
Jenkinsfileand stored in source control for versioning and collaboration.Branch Builds: Automatically runs pipelines for branches and pull requests.
Code Review: Allows reviewing the pipeline definition alongside the application code.
My Task Progress
1️⃣ Created a New Pipeline Job:
In Jenkins, instead of a Freestyle Project, I selected the Pipeline type.
This allows me to write and manage the pipeline script.
2️⃣ Followed the Official Jenkins Hello World Example:
- I referred to the official Jenkins documentation and implemented a Declarative Pipeline.
3️⃣ Wrote a Basic Jenkinsfile: Here’s the Jenkinsfile I used for this task:
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building the application...'
}
}
stage('Test') {
steps {
echo 'Running tests...'
}
}
stage('Deploy') {
steps {
echo 'Deploying the application...'
}
}
}
}
4️⃣ Committing the Jenkinsfile:
- Added the
Jenkinsfileto the project repository to follow best practices for Pipeline-as-Code.
What I Learned Today
The Declarative Pipeline syntax is user-friendly and structured, making it easy to manage even for beginners.
Writing a
Jenkinsfileensures pipelines are version-controlled and reviewed like application code.Jenkins can automate builds, tests, and deployments seamlessly through pipelines.


