Skip to main content
Jenkins Pipeline - Different types of CI pipelines and stages_
Posted On: 5 June 2022

Jenkins is one of the most powerful tools for continuous integration and continuous delivery (CI/CD). It seamlessly fits into the DevOps practice and helps developers with hassle-free CI/CD.

This explains why, as of May 2022, more than 55900 companies use this Java-written platform. It has a market share of 51.35% in the continuous integration sector and continues to be at the helm.

That said, Jenkins Pipeline is one of the critical elements of Jenkins DevOps success.

Ready to Get Started?

Let our team experts walk you through how ACCELQ can assist you in achieving a true continuous testing automation

What is Jenkins Pipeline?

Jenkins Pipeline is a collection of plugins that helps launch “build, test, and deploy” processes in a pre-defined sequence. The existence of over 1000 plugins within the Jenkins ecosystem means developers can opt for the best resources to execute and evolve CI/CD pipelines.

In essence, the Jenkins Pipeline consolidates a set of instructions that are essential for building and testing applications in a repeatable manner. The idea is to extend the CD practice capabilities, which aims to bring the software from version control to a user-facing release.

By writing the definition of Jenkins Pipeline, developers can create a robust, maintainable, and scalable development environment that fills the gap between release and production. As soon as the Jenkins Pipeline is implemented in the source control repository, it advocates for the creation of pipelines for each branch. It further creates audit trails by default and executes against any changes to the code for testing and deployment.

It is important to note that a single source of truth prevails for this pipeline so that everything is known, accessible, and editable at every point through time by project members.

Different Types of Jenkins CI/CD Pipelines

Web Application-ACCELQ

The definition of a Jenkins Pipeline is constituted in the text file called Jenkinsfile. This file defines the implementation of Jenkins Pipeline in the source control repository. Moreover, all the aforementioned pipeline benefits accrue from this definition.

The Jenkinsfile supports two syntaxes – Declarative and Scripted. While Scripted syntax and the associated Scripted pipelines have been around for some time, Declarative syntax and its associated Declarative pipelines are relatively new.

Scripted Pipeline

A scripted pipeline uses the Groovy (JVM-based) language to create a pipeline as code. Some software developers prefer this pipeline because the use of Groovy code paves the way for making numerous APIs available. As a result, developers can orchestrate rather complex CD pipelines.

For creating scripted pipelines in Jenkins, developers must include a pipeline code within the UI and save it. Here’s the general syntax of a scripted pipeline:

Jenkinsfile (Scripted Pipeline)

node {  

    stage('Build') { 

       …….

    }

    stage('Test') { 

       …….

    }

    stage('Deploy') { 

       …….

    }

}

Source: Jenkins.io

Problems with scripted pipeline:

  • The imbalance between developers’ experience in Groovy and Jenkins creates an impedance mismatch that is not easy to remove.
  • Although scripted syntax is powerful and expedites the creation of complex pipelines, it concurrently makes the pipeline hard to read and hard to manage.

Declarative Pipeline

The declarative pipeline follows a relatively newer syntax, which narrows the scope of the pipeline structure through a pre-defined “minimum necessary structure.” On the technical front, the declarative syntax follows a conditional statement logic that generates a series of stages, executed sequentially throughout the pipeline’s lifecycle. Here’s the general syntax of a declarative pipeline:

Jenkinsfile (Declarative Pipeline)

pipeline {

    agent any 

    stages {

        stage(‘Build’) { 

            steps {

                …….

            }

        }

        stage(‘Test’) { 

            steps {

                …….

            }

        }

        stage(‘Deploy’) { 

            steps {

                …….

            }

        }

    }

}

Source: Jenkins.io

Problems with declarative pipeline:

    • Since declarative pipelines don’t make use of Groovy code, the declarative syntax doesn’t access valuable APIs. But, at the end of the day, the declarative syntax is uncomplicated to read and comparatively easier to manage.

The Concept of Stages in Jenkins Pipeline

Jenkins defines two kinds of stages for declarative pipelines:

Parallel Stages

A nested, variable number of stages can be executed in parallel in declarative pipelines. This is a common and well-known use case for carrying out “build” and “test” across different platforms. Whenever there’s a problem in these parallel stages, the developer can abort them using the failFast option.

Sequential Stages

The sequential stages facility extends the capability of parallel stages by allowing for nesting multiple stages within each parallel branch. A sequential stage is an excellent choice when a developer would like more visibility into the sequence of stages and the order in which they are executed.

The nested stage facility in declarative pipelines makes it easier to follow the lifecycle of a pipeline. It also allows developers to view the set of logical states more profoundly. The good thing is that Jenkins evolves rapidly around stages, which is the core of CI/CD. So, the chances are that the coming improvements will further simplify the process of testing and deploying applications.

Integrate Test Automation with Jenkins

Test automation is integral to the DevOps philosophy, courtesy of its ability to speed up software development and bring forth the value of repeatability in a sophisticated development environment.

The CI/CD agile software development process fairs out in such a way that it brings with it the need to automate tests. Hence it’s here that the opportunity to tap into the power of test automation is increasingly tempting.

Considering Jenkins’ prowess in driving CI/CD, it’s a natural choice to integrate test automation with Jenkins.

ACCELQ provides a native Jenkins plugin to help run CI pipeline-specific automation scripts on Jenkins and get the best performance. Download here!

Reach out to us for more info.

Nidhi Achhaa | Content Specialist at ACCELQ

Nidhi specializes in technology-based content and strives to create a unique, customized, and compelling piece with a flavor of SEO. A writer with a love for words and a storyteller at heart.

   

Related Posts

Overview of Appium 2.0-ACCELQBlogTesting
7 October 2022

Overview of Appium 2.0 New Features and Updates

With Appium 2.0, Appium aims to evolve from being a tool and automation library to a platform for a whole automation ecosystem
Salesforce Health Cloud-ACCELQBlogEnterpise App Test Automation
2 November 2022

What is Salesforce Health Cloud? Here Are the Top Benefits

Salesforce Health Cloud empowers healthcare organizations with features that best suit the needs of the industry

Get started on your Codeless Test Automation journey

Talk to ACCELQ Team and see how you can get started.

Close Menu