Back to blog

Declarative Pipeline Syntax 1.0 is now available

Patrick Wolf
February 3, 2017

This is a guest post by Patrick Wolf, Director of Product Management at CloudBees and contributor to the Jenkins project.

I am very excited to announce the addition of Declarative Pipeline syntax 1.0 to Jenkins Pipeline. We think this new syntax will enable everyone involved in DevOps, regardless of expertise, to participate in the continuous delivery process. Whether creating, editing or reviewing a pipeline, having a straightforward structure helps to understand and predict the flow of the pipeline and provides a common foundation across all pipelines.

Pipeline as Code

Pipeline as Code was one of the pillars of the Jenkins 2.0 release and an essential part of implementing continuous delivery (CD). Defining all of the stages of an application’s CD pipeline within a Jenkinsfile and checking it into the repository with the application code provides all of the benefits inherent in source control management (SCM):

  • Retain history of all changes to Pipeline

  • Rollback to a previous Pipeline version

  • View diffs and merge changes to the Pipeline

  • Test new Pipeline steps in branches

  • Run the same Pipeline on a different Jenkins server

Getting Started with Declarative Pipeline

We recommend people begin using it for all their Pipeline definitions in Jenkins. The plugin has been available for use and testing starting with the 0.1 release that was debuted at Jenkins World in September. Since then, it has already been installed in over 5,000 Jenkins environments.

If you haven’t tried Pipeline or have considered Pipeline in the past, I believe this new syntax is much more approachable with an easier adoption curve to quickly realize all of the benefits of Pipeline as Code. In addition, the pre-defined structure of Declarative makes it possible to create and edit Pipelines with a graphical user interface (GUI). The Blue Ocean team is actively working on a Visual Pipeline Editor which will be included in an upcoming release.

If you have already begun using Pipelines in Jenkins, I believe that this new alternative syntax can help expand that usage.

The original syntax for defining Pipelines in Jenkins is a Groovy DSL that allows most of the features of full imperative programming.

This syntax is still fully supported and is now referred to as "Scripted Pipeline Syntax" to distinguish it from "Declarative Pipeline Syntax." Both use the same underlying execution engine in Jenkins and both will generate the same results in Pipeline Stage View or Blue Ocean visualizations. All existing Pipeline steps, Global Variables, and Shared Libraries can be used in either. You can now create more cookie-cutter Pipelines and extend the power of Pipeline to all users regardless of Groovy expertise.

Declarative Pipeline Features

  • Syntax Checking

    • Immediate runtime syntax checking with explicit error messages.

    • API endpoint for linting a Jenkinsfile.

    • CLI command to lint a Jenkinsfile.

  • Docker Pipeline integration

    • Run all stages in a single container.

    • Run each stage in a different container.

  • Easy configuration

    • Quickly define parameters for your Pipeline.

    • Quickly define environment variables and credentials for your Pipeline.

    • Quickly define options (such as timeout, retry, build discarding) for your Pipeline.

    • Round trip editing with the Visual Pipeline Editor (watch for preview release shortly).

  • Conditional actions

    • Send notifications or take actions depending upon success or failure.

    • Skip stages based on branches, environment, or other Boolean expression. release shortly)

Where Can I Learn More?

Be on the lookout for future blog posts detailing specific examples of scenarios or features in Declarative Pipeline. Andrew Bayer, one of the primary developers behind Declarative Pipeline, will be presenting at FOSDEM in Brussels, Belgium this weekend. We have also scheduled an online Jenkins Meetup (JAM) later this month to demo the features of Declarative Pipeline and give a sneak peek at the upcoming Blue Ocean Pipeline Editor.

In the meantime, all the Pipeline documentation has been updated to incorporate a Guided Tour, and a Syntax Reference with numerous examples to help you get on your way to using Pipeline. Simply upgrade to the latest version, 2.5 or later of the Pipeline in Jenkins to enable all of these great features.

About the author

Patrick Wolf

This author has no biography defined. See social media links referenced below.