Jenkins Declarative Pipeline
#90daysdevopschallenge
#day26
If you are new to Jenkins then Please go through from basic:
Pipeline:
The Pipeline is a collection of jobs and events that are interlinked with one another in a sequence.
JenkinsFile:
Jenkins pipeline can be defined by a text file called JenkinsFile. By using JenkinsFile you can implement a pipeline as a code and this can be defined by using DSL (Domain Specific Language). You can make pipelines automatically for all branches and can execute pull requests with just one JenkinsFile.
In Jenkins two types of syntax you can use to define the pipeline.
Declarative Pipeline:
Declarative is a more recent and advanced implementation of a pipeline as a code. Its syntax offers a simple way to create a pipeline.
Scripted Pipeline:
Scripted was the first and most traditional implementation of the pipeline as a code in Jenkins. It was designed as a general-purpose DSL (Domain Specific Language) built with Groovy.
Pipeline syntax
pipeline {
agent any
stages {
stage('Build') {
steps {
//
}
}
stage('Test') {
steps {
//
}
}
stage('Deploy') {
steps {
//
}
}
}
}
Jenkins Pipeline Concepts:
Pipeline:
This is the user-defined block, which contains all the processes such as build, test, deploy, etc. It is a group of all the stages in JenkinsFile.
Syntax: pipeline{ }
Stage:
This block contains a series of steps in the pipeline.
pipeline {
agent any
stages {
stage('Build') {
steps {
//
}
}
}
}
Step:
A Step is a single task that executes a specific process at a defined time. A pipeline defines a series of steps defined within a stage block.
pipeline {
agent any
stages {
stage('Build') {
steps {
//
}
}
}
}
Task-01
Create a New Job, this time select Pipeline instead of Freestyle Project. Create a new pipeline for printing the "Hello World!".
Step 1: Create a new job.
Step 2: Enter the name of the pipeline and select "pipeline".
Step 3: Write the Script for the pipeline and click on "Save".
Step 4: Run the pipeline by clicking on "Build Now".
Step 5: After Successfully running the pipeline. Check the Console Output.
In the Next Article will read more about Jenkins Pipeline with docker..
Thank you for giving your precious time to read this blog/article and if any suggestions or improvements are required on my blogs feel free to connect on LinkedIn Unnati Gupta.
Subscribe to my newsletter
Read articles from Unnati Gupta directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Unnati Gupta
Unnati Gupta
๐จโ๐ป DevOps Engineer at 6D Technology Passionate about bridging the gap between development and operations, I'm a dedicated DevOps Engineer at 6D Technology. With a strong belief in the power of automation, continuous integration, and continuous delivery, I thrive in optimizing software development pipelines for efficiency and reliability. ๐ Exploring the DevOps Universe In my articles, I delve into the fascinating world of DevOps, where I share insights, best practices, and real-world experiences. From containerization and orchestration to CI/CD pipelines and infrastructure as code, I'm here to demystify the complex and empower fellow developers and ops enthusiasts. ๐ Blogging for Knowledge Sharing As a tech enthusiast and a lifelong learner, I'm committed to sharing knowledge. My articles aim to simplify complex concepts and provide practical tips that help teams and individuals streamline their software delivery processes. ๐ Connect with Me Let's connect and explore the ever-evolving landscape of DevOps together. Feel free to reach out, comment, or share your thoughts on my articles. Together, we can foster a culture of collaboration and innovation in the DevOps community. ๐ Social Links LinkedIn: https://www.linkedin.com/in/unnati-gupta-%F0%9F%87%AE%F0%9F%87%B3-a62563183/ GitHub: https://github.com/DevUnnati ๐ฉ Contact Have questions or looking to collaborate? You can reach me at unnatigupta527@gmail.com Happy Learning!!