top of page

Jenkins Pipeline

Pipeline in Jenkins is a group of jobs (or events) that are interlinked in a particular sequence. Jenkins Pipeline is a set or suite of plugins that provides support for implementation and integration of Continuous Delivery pipelines into Jenkins.

The Pipeline also provides a set of tools that are useful for modeling simple as well as complex delivery pipelines ‘as code’ through ‘Pipeline Domain-Specific Language (DSL)’ syntax.

Every job in the Jenkins pipeline has some dependency on one or more events. Continuous delivery pipeline in Jenkins consists of four states – Build, Deploy, Test, and Release. Each of these states consist of events that execute in a sequence.

What Is Jenkinsfile?

Now that you understand what is Jenkins pipeline, we can dive deeper into the concept. The entire definition of a Jenkins Pipeline is written into a text file called Jenkinsfile. It contains the steps required for running a Jenkins Pipeline. ‘Pipeline as code’ can be implemented using Jenkinsfile and Domain Specific Language (DSL) is used for defining the same.

Jenkinsfile can also be committed to the source control repository of the project. With Jenkinsfile, the CD Pipeline is also treated as a part of the application that is versioned, committed, and reviewed like any other piece of code.

Some of the major benefits of Jenkinsfile are:

  • Single Jenkinsfile can be used for creating a Pipeline build process for all the branches and executing pull requests.

  • The implementation in a Pipeline can be reviewed like normal source code.

  • Audit trail of the Pipeline.

  • Singular source for the Pipeline can be viewed as well as edited by multiple members associated with the project.

Though Pipeline can be defined either in web UI or with a Jenkinsfile, it is recommended to define what is Jenkins Pipeline in a Jenkinsfile and maintain the same in a source control repository.

Syntax For Defining A Jenkinsfile

To define what is Jenkins pipeline, Jenkinsfile can be written using the following types of Syntax:

a. Declarative

Declarative Pipeline is a recent feature of Jenkins Pipeline that makes reading and writing the Pipeline code a lot easier. Unlike Scripted Syntax with Pipelines, Declarative Syntax helps in controlling different aspects of the Pipeline in a simplistic manner.


  1. Modern way of developing Pipelines and favored by the company behind Jenkins

  2. Structured. Simpler syntax

  3. Easy to read

  4. Steep learning curve

  5. Best integration with Blue Ocean interface

  6. Allows restarting from specific stage


  1. Less suitable for Pipelines with complex logic

  2. Lack of compatibility with old plugins

  3. Restrictive syntax

b. Scripted

Scripted Pipeline is a more traditional way of writing a Jenkins Pipeline as code. It uses traditional Groovy-based syntax. The Web UI of Jenkins is normally used for writing the Scripted Pipeline in a Jenkinsfile.


  1. Flexibility powered by Groovy language

  2. Extensibility

  3. Allows restarting from specific Stage


  1. Shallow learning curve

  2. Less readability harder to maintain

  3. Harder to maintain

  4. No integration with Blue Ocean

  5. Restart from Stage option unavailable

Run the pipeline

Now lets configure the Jenkins pipeline. Following are the steps to create Jenkins Pipeline.

Step 1:

Select “New Item” from the dashboard of the Jenkins instance

Step 2:

Name the item and select pipeline as the style of the job item.

Step 3:

Scroll down and select the definition of the Pipeline. Here we get two options.

  1. One is the Pipeline script from SCM which is for Declarative Pipeline

  2. Another is the Pipeline script which is for Scripted Pipeline that we will write directly on UI.

If it is the Pipeline Script, which will be written directly on UI, Need to write it on Script place (Scripted pipeline)

If we are selecting the Pipeline script from SCM definition, then we need to select the Git > SCM Repository URL > Credentials. (Declarative Pipeline).

Declarative Pipeline from SCM

In the Declarative pipeline, We need to select the repository of the Jenkinsfile, Credentials, Branch and the path of the Jenkinsfile as shown in the above screenshot.

Important Concepts Of Jenkins Pipeline

Moving on with what is Jenkins pipeline, here are some basic concepts that need to be well-understood if you are planning to use the Jenkins Pipeline:

a. Pipeline

The Pipeline consists of a set of instructions written as code. It defines the entire build process, which ideally consists of different stages for building, testing, and delivering the application.

b. Node

A node is a machine that is a part of the Jenkins environment. The Jenkins Pipeline executes on a node block that is usually a part of the Scripted Pipeline syntax.

c. Stage

Stage in a Jenkins Pipeline consists of a unique subset of tasks such as Build, Test, Deploy, etc. The Stage block is used by many plugins for providing the visualization of Jenkins status (and progress).

d. Step

Step is a single task that tells Jenkins what exactly needs to be done. For example, setting an environment variable can be done in a step, executing a build command can also be a step. On the whole, a Jenkins Pipeline constitutes a series of steps.

Advantages Of Using Jenkins Pipeline

Jenkins Pipeline is instrumental in adding a rich set of automation tools onto Jenkins. Hence, Jenkins can be used for simple continuous integration as well as for comprehensive CD pipelines.

These are some of the primary reasons for using the Jenkins Pipeline:

  • As the Jenkins Pipeline is implemented as code, it can be checked in the source control repository. Teams can view, edit, as well as iterate upon the delivery pipeline.

  • Jenkins Pipelines are robust. A Pipeline is automatically resumed in case the server witnesses an unplanned restart.

  • Pipeline process can pause and wait for input for any input from the user.

  • Pipelines are versatile as they can be used for realizing complex CD requirements, including performing work in parallel.

  • Jenkins Pipelines are extensible by plugin developers and users with Pipeline Shared Libraries.

The Tech Platform



bottom of page