Jenkins Declarative Pipeline

#90DaysOfDevOps

#Day24

What is Pipeline?

A pipeline is a collection of steps or jobs interlinked in a sequence.It defines your entire build process, which typically includes stages for building an application, testing it and then delivering it.

A Jenkinsfile can be written using two types of syntax - Declarative and Scripted.

Declarative Vs Scripted

DeclarativeScripted
We can start from any particular pipeline using Restart from StageWe can't start from a particular stage
By default, Declarative Checkout SCM stage is created if GitHub repo is usedNo extra stage is added to the pipeline

Advantage of Pipeline

  • Durable: Pipelines can survive both planned and unplanned restarts of the Jenkins controller. Freestyle projects are not durable.

  • Versatile: Pipelines support complex real-world CD requirements, including the ability to fork/join, loop, and perform work in parallel.

  • Code: The code is stored in a text file called the Jenkinsfile which can be checked into a SCM

  • Extensible:It can integrate with several other plugins

Creating a simple Declarative pipeline

  • Go to Jenkins Dashboard > New Item

  • Enter the name of your project and select the Pipeline option and Click OK

  • Now in the pipeline section add the code below

    • Click on Save

    • Click on Build Now

Your first declarative pipeline is created.

Thank you for reading!!

~Sujata Kumari