Published on

Declarative vs. Imperative CI

Authors
  • avatar
    Name
    Skim
    Twitter

Declarative Pipeline

This approach limits what you can do to some extent, but it does so for a good reason. Declarative pipelines are written in a concise, human-readable format, focusing on the "what" rather than the "how." They offer a structured and simplified way of defining CI/CD workflows.

Scripted/imperative Pipeline

In contrast, scripted pipelines give you more control. They allow you to write custom Groovy scripts to define your workflows. This flexibility can be powerful but comes at the cost of complexity.

Complexity vs. Simplicity

Declarative pipelines are recommended for most use cases due to their simplicity. They're easy to read, write, and maintain, making them suitable for straightforward CI/CD needs. Scripted pipelines, on the other hand, are more appropriate for complex, custom workflows.

Choosing the Right Approach

Selecting the right approach between declarative and scripted pipelines depends on several factors:

  1. Project Complexity: consider the complexity of your CI/CD needs. Declarative pipelines are the go-to choice for straightforward projects, while scripted pipelines are better suited for intricate workflows.
  2. Team Expertise: assess your team's expertise. Declarative pipelines are more accessible to a wider audience, making them a better fit for teams with varying levels of experience.
  3. Maintenance Effort: think about the long-term maintenance of your pipelines. Declarative pipelines simplify this aspect, as updates mainly involve modifying configuration files.
  4. Customization Needs: evaluate how much customization your project requires. If you need fine-grained control and advanced scripting, scripted pipelines might be necessary.

Source: https://medium.com/globant/jenkins-pipeline-declarative-vs-scripted-21f8688ee16a