Skip to main content

Command Palette

Search for a command to run...

♻️Day 26 - Jenkins Declarative Pipeline

Published
2 min read
♻️Day 26 - Jenkins Declarative Pipeline
S
Hi, I’m Sarika 👋 I’m a QA Engineer with 2+ years of experience in software testing. I have hands-on experience in: * Functional & Regression Testing * API Testing using Postman * Database validation using SQL * Cross-browser testing Currently, I’m focusing on: * Automation Testing using Selenium & Playwright (Java) * Building real-world testing frameworks * End-to-End testing (UI + API + DB) This blog is where I share: * What I learn daily * Real testing scenarios * Practical examples (not just theory) * Interview-focused concepts 🚀 Learning | Building | Sharing Follow me on LinkedIn: https://www.linkedin.com/in/sarika-kamble-3153b3218/

One of the most important parts of your DevOps and CICD journey is a Declarative Pipeline Syntax of Jenkins....

🌿Some terms for your Knowledge:

What is Pipeline - A pipeline is a collection of steps or jobs interlinked in a sequence.

In Jenkins, a pipeline is a series of automated steps that allow you to model and automate the process of delivering software. Jenkins supports two types of pipelines:

Declarative: Declarative is a more recent and advanced implementation of a pipeline as a code.

Scripted: 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.

🌿Why you should have a Pipeline

The definition of a Jenkins Pipeline is written into a text file (called a Jenkinsfile) which in turn can be committed to a project’s source control repository.
This is the foundation of "Pipeline-as-code"; treating the CD pipeline as a part of the application to be versioned and reviewed like any other code.

Creating a Jenkinsfile and committing it to source control provides a number of immediate benefits:

  • Automatically creates a Pipeline build process for all branches and pull requests.

  • Code review/iteration on the Pipeline (along with the remaining source code).

🌿Pipeline syntax

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                //
            }
        }
        stage('Test') {
            steps {
                //
            }
        }
        stage('Deploy') {
            steps {
                //
            }
        }
    }
}

🌿Task-01:

★ Create a New Job, this time select Pipeline instead of Freestyle Project.

  • Complete the example using the Declarative pipeline

  • Build the Job and click on "Build Now" to start the job.

  • After a build is completed, you can view the console output by clicking on the "Console Output" link on the build page.

📚Happy Learning :)

More from this blog

S

Sarika Tech Journey

42 posts