Search code examples
jenkinsjenkins-pipelinejenkins-declarative-pipeline

What exactly is "Declarative Pipeline" in Jenkins? How to switch from the previous "pipeline" concept?


I am a bit confused about the concept of "Declarative Pipeline" in Jenkins.

Right now, I am using several Jobs of the "Multibranch-Pipeline" type of job. I maintain "Shared Libraries", which combine a vars folder with reusable functionality. In the same repository, there is also a jobs folder, that contain "complete pipelines", that are supposed to be configured with a normal "Pipeline" type of job, and then these get triggered from Jenkinsfiles that are watched by the Multibranch-Pipeline-Job.

How to convert this to a "Declarative Pipeline". What are the best documentation resources to get started on the topic "normal vs. Declarative".


Solution

  • Here's a couple of good articles to get you started on scripted vs. declarative pipelines (I'm not the author).

    https://www.blazemeter.com/blog/how-to-use-the-jenkins-scripted-pipeline https://www.blazemeter.com/blog/how-to-use-the-jenkins-declarative-pipeline

    The paragraph below is from the second article and sums it up nicely. One big difference that I see between scripted and declarative pipelines is that declarative pipelines are expected to be stored in a source code control system and checked out each time they're run. Declarative pipelines are a newer way than scripted, but scripted pipelines are not going away.

    Jenkins provides you with two ways of developing your pipeline code: Scripted and Declarative. Scripted pipelines, also known as “traditional” pipelines, are based on Groovy as their Domain-specific language. On the other hand, Declarative pipelines provide a simplified and more friendly syntax with specific statements for defining them, without needing to learn Groovy.