๐๐ Day 26 DevOps Challenge - Exploring Jenkins Declarative Pipeline with Easy Steps! ๐
Table of contents
- Introduction
- ๐ ๏ธ What is a Pipeline?
- Declarative vs. Scripted Approaches
- ๐ Declarative Approach
- ๐ด Scripted Approach
- A basic example of a Declarative Pipeline:
- The Imperative Need for a Pipeline
- ๐ง Automation
- ๐ฏ Consistency
- ๐ Traceability
- ๐ Reproducibility
- โก Speed
- ๐ Scale
- Task-01 Create a Hello_World job using the declarative pipeline.
Introduction
In the dynamic landscape of continuous integration and delivery, the Jenkins Declarative Pipeline emerges as a potent tool for orchestrating and optimizing software delivery processes. This mechanism streamlines the configuration of your continuous delivery pipeline, analogous to a meticulously crafted recipe guiding the journey from raw ingredients to a delectable final product, served piping hot! ๐ฒ
๐ ๏ธ What is a Pipeline?
Visualize a pipeline as a magical conduit that transforms raw code into a functional application through a well-defined sequence of steps. Like a conveyor belt in a factory, the pipeline ensures a seamless transition from code creation to building, testing, and ultimate delivery. ๐
Declarative vs. Scripted Approaches
๐ Declarative Approach
Think of the Declarative approach as following a recipe step by step, ensuring a consistent outcome. It simplifies the process and is particularly suitable for those new to the concept. It's like meticulously executing a culinary recipe to achieve a delectable dish. ๐ณ
๐ด Scripted Approach
In contrast, the Scripted approach empowers you with the freedom of a chef, allowing for unique and creative implementations. It's akin to crafting a dish with your personal flair, making it ideal for those well-versed in the process. ๐ง
A basic example of a Declarative Pipeline:
pipeline {
agent any
stages {
stage('Build') {
steps {
// Build your application here
}
}
stage('Test') {
steps {
// Run tests here
}
}
stage('Deploy') {
steps {
// Deploy your application here
}
}
}
}
In this example, the pipeline has three stages: Build, Test, and Deploy.
Each stage contains a series of steps, and Jenkins will automatically manage the execution of these stages in the specified order.
The Imperative Need for a Pipeline
๐ง Automation
Picture having an indefatigable robot toil through mundane and repetitive tasks, liberating you to focus on high-value endeavors. The pipeline acts as your automation companion, taking care of the tedious work. ๐ค
๐ฏ Consistency
The Declarative Pipeline guarantees a consistent outcome every time you embark on your software journey. Similar to a perfected recipe, it ensures that your final product is consistently delightful and reliable. ๐ฐ
๐ Traceability
One of its remarkable features is traceability, meticulously recording each step of your process. This feature empowers you to track changes and understand the evolution of your project over time. ๐
๐ Reproducibility
Just like a cherished recipe enables you to recreate a beloved dish, the pipeline offers the ability to reproduce software builds reliably. This enhances project stability and confidence. ๐ฅ
โก Speed
As an adept multitasker, the pipeline expedites development by simultaneously managing multiple tasks. It ensures efficient and timely execution of your software workflow. ๐จ
๐ Scale
Whether you're catering to a grand event or a cozy gathering, the Declarative Pipeline effortlessly accommodates projects of varying sizes. Its scalability ensures seamless performance in diverse scenarios. ๐ฝ๏ธ
Task-01 Create a Hello_World job using the declarative pipeline.
Step 1: Launch an EC2 Instance named "JENKINS-SERVER"
- Launch an EC2 instance on your preferred cloud provider and name it "JENKINS-SERVER".
Step 2: Install JAVA and JENKINS on the Jenkins-Server
SSH into your EC2 instance.
Install Java and Jenkins on the instance.
Step 3: Access Jenkins Dashboard and Create a New Pipeline Job
Open a web browser and navigate to
http://<public_ip>:8080
(replace<public_ip>
with your Jenkins server's public IP).Log in to the Jenkins dashboard.
Click on "New Item."
Enter the name for the job as "HelloWorldPipeline."
Choose "Pipeline" as the project type and click "OK."
Step 4: Define Declarative Pipeline Script
In the Pipeline section of the job configuration page:
pipeline {
agent any
stages {
stage('Hello World') {
steps {
echo 'Hello World'
}
}
}
}
Step 5: Build the Job
Save the job configuration.
Click on "Build Now" to start the job.
Step 6: View Build Status and Console Output
Once the build completes, you'll see the build status on the job's page.
Click on the build number to view details.
Click on "Console Output" to see the complete output of the job.\
Please note that you'll need to adapt the steps and the provided Declarative Pipeline script to your actual setup and environment. Also, make sure you have Jenkins properly set up on your EC2 instance and have the necessary plugins installed for pipeline execution.
Conclusion: Jenkins Declarative Pipeline is your chef's assistant, taking your recipe (pipeline) and turning it into a delicious software dish. With automation, consistency, and traceability, you're on your way to becoming a master chef of software delivery! ๐๐