Glimpse of Pipeline in Jenkins

Reading Time: 3 minutes

Hi readers, In this blog, we will be creating the Sample Jenkins pipeline also we will be looking at basic syntax of the pipeline.

Pipeline Stucture

Jenkins Pipeline is a suite of plugins that supports implementing and integrating continuous delivery pipelines into Jenkins.

continuous delivery (CD) pipeline is an automated expression of your process for getting software from version control right through to your users and customers.

Let’s get started with the basic syntax which can be used to start defining a pipeline.

Node

node is a machine that is part of the Jenkins environment and is capable of executing a Pipeline. Also, a node block is a basic key part of Scripted Pipeline syntax.

node {
	// commands to run
}

Stages

stage block defines a conceptually distinct subset of tasks performed through the entire Pipeline, which is used by many plugins to visualize or present Jenkins Pipeline’s status/progress.

stages {
        stage('Test') { 
            steps {
                // 
            }
        }
}

Steps

A stepsis a single task. Fundamentally, a step tells Jenkins what to do at a particular point in time. For example, to execute the shell command make use of the sh step: sh 'make'.

steps {
                // 
            }

SCRIPTS

A Scrips is also possible to specify shell (or batch) scripts to be executed in a pipeline.

sh "sbt clean compile"

Creating a Pipeline job

To create a new pipeline the first step is to create a new Pipeline job. To do so, from the main Jenkins screen select “New Item”, specify a job name ,and then “Pipeline”.

Creating New Pipeline job

In the pipeline configuration page, the first three sections are the same as for a traditional Jenkins job (General, Build Triggers ,and Advanced Project Options).

Setting Job

In the Pipeline section, we can choose between two options in order to define the job pipeline. Either using the inline editor or loading the pipeline from a JenkinsFile.

Pipeline Script

I have used the pipeline script for our sample pipeline for the job. After clicking save we can our job into Jenkins if we click on build now we see the pipeline like as shown below.

Running Pipeline

Conclusion

Jenkins Pipeline is a combination of plugins that support the integration and implementation of continuous delivery pipelines using Jenkins. A pipeline has an extensible automation server for creating simple or complex delivery pipelines “as code,” via pipeline DSL (Domain-specific Language)

Reference

https://www.jenkins.io/doc/book/pipeline/