DEV Community

Harshad Ranganathan
Harshad Ranganathan

Posted on • Updated on • Originally published at

Jenkins Pipeline as Code

Originally published at

Jenkins Pipeline is a suite of plugins which supports implementing and integrating continuous delivery pipelines into Jenkins.

Need for Jenkins Pipeline as Code

Over time, Jenkins, like most other self-hosted CI/CD tools resulted in:

  • Accumulation/tendency to create vast number of jobs
  • Hard and costly maintenance
  • Heavy reliance on UI
  • Lack of powerful ways to specify conditional logic

Features of Pipeline as Code

  • Pipelines are implemented as code and typically checked into source control, serving as a single source of truth enabling the team members to edit, review, and iterate upon their pipeline.

  • Pipelines can optionally stop and wait for human input or approval before continuing the Pipeline run.

  • Pipelines support complex real-world requirements

    • Conditional executions
    • Chaining jobs
    • Linear/Complex flows
  • The Pipeline plugin supports custom extensions to its DSL and multiple options for integration with other plugins.

Pipeline Autocompletion in IntelliJ

To enable code completion follow below steps:

  1. Download Pipeline GDSL (http://(yourjenkinsurl)/job/(yourpipelinejob)/pipeline-syntax/gdsl) from your jenkins.
  2. Add Groovy SDK support to Intellij.
  3. Place the GDSL file inside src directory of your project and mark the src folder as Sources Root.
  4. Open the GDSL file. Now, IntelliJ will show a message DSL descriptor file has been changed and isn't currently executed.. Click Activate.
  5. Now create your .groovy jenkins file and write the code, auto completion will work.

Snippet Generator

You can also generate snippets of code for the pipeline steps using the Snippet Generator feature available in Jenkins (http://(yourjenkinsurl)/job/(yourpipelinejob)/pipeline-syntax/) which you can then make use of in your pipeline.


Replay feature allows you to test your pipeline code without having to commit the changes to your Repo. Once you have tested the code you can then push your changes.

Jenkins Declarative Pipeline Example


Top comments (0)