Day 26 - Jenkins Declarative Pipeline

Day 26 - Jenkins Declarative Pipeline

A Pipeline is a collection of steps or jobs interlinked in a sequence. It is a sequence of stages or steps that define the flow of activities involved in building, testing, and deploying software applications. It represents the entire workflow from source code management to production deployment.

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.

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

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

  1. Log in to your Jenkins instance and navigate to the Jenkins dashboard.

2. Click on "New Item" to create a new job.

  1. Enter a name for your job ( "FirestJob") and select "Pipeline" as the job type.

  1. Click on "OK" to proceed to the job configuration.

  2. Enter a description.

  1. In the Pipeline section, select "Pipeline script" as the Definition.

  2. Enter the following code:-

  1. Click on "Save" to save the job configuration.

  2. Now go to Dashboard and click on "Build Now" and we can see "Stage View".

  1. Once the build is successful, you can go to the console output and check the output of the build.

Thank you for reading...

Happy Learning :)