# Formatting Jenkins Declarative Pipeline Code

**URL:** <https://community.jenkins.io/t/formatting-jenkins-declarative-pipeline-code/30326>\
**Category:** Ask a question\
**Tags:** question, pipeline\
**Created:** [April 25, 2025, 12:30pm UTC](https://community.jenkins.io/t/formatting-jenkins-declarative-pipeline-code/30326 "2025-04-25T12:30:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexander.bohn](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@alexander.bohn](https://community.jenkins.io/u/alexander.bohn)\
**Post date:** [April 25, 2025, 12:30pm UTC](https://community.jenkins.io/t/formatting-jenkins-declarative-pipeline-code/30326/1 "2025-04-25T12:30:05Z")

</div>

Hello Jenkins Community,

I do not understand how to format my Jenkins Declarative Pipeline code that I have written in a Jenkinsfile. By “format” I mean applying proper indentation to every line. I have found some extensions for VS Code, like Groovy Lint, and some paid IntelliJ extensions, but I am not satisfied with them.

Can anyone help me with how to properly indent Jenkinsfile code?

Best regards  
Alexander Bohn

---

<div class="post-metadata">

**Author:** ![krachynski](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/krachynski/32/2674_2.png) [@krachynski](https://community.jenkins.io/u/krachynski)\
**Post date:** [April 25, 2025, 2:37pm UTC](https://community.jenkins.io/t/formatting-jenkins-declarative-pipeline-code/30326/2 "2025-04-25T14:37:23Z")

</div>

Honestly, properly indenting Groovy files depends entirely on your development team. It’s up to you to decide how that actually looks.

That said, I am personally happy with how IntelliJ IDEA formats Groovy code by default. All formatting in IDEA can be configured however you prefer.

---

<div class="post-metadata">

**Author:** ![Artalus](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/artalus/32/11413_2.png) [@Artalus](https://community.jenkins.io/u/Artalus)\
**Post date:** [April 28, 2025, 10:28am UTC](https://community.jenkins.io/t/formatting-jenkins-declarative-pipeline-code/30326/3 "2025-04-28T10:28:29Z")

</div>

Groovy Lint uses [CodeNarc](https://codenarc.org) under its hood, which is venerable and technically supports custom configuration - but dealing with it has always been a pain to me. AFAIK the only real competitor to `npm-groovy-lint + codenarc` duo would be [Spotless](https://github.com/diffplug/spotless). I don’t have any experience with it, but from what I understand, it’s supposed to integrate into Maven / Gradle buildsystem.

If you use [Prettier](https://prettier.io), there are some Groovy plugins for it – but they are in various state of disarray.

---

<div class="post-metadata">

**Author:** ![krachynski](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/krachynski/32/2674_2.png) [@krachynski](https://community.jenkins.io/u/krachynski)\
**Post date:** [May 6, 2025, 5:25pm UTC](https://community.jenkins.io/t/formatting-jenkins-declarative-pipeline-code/30326/4 "2025-05-06T17:25:57Z")

</div>

Hmm, that’s an interesting idea. We’re currently integrating Spotless into Maven projects to handle checking our code and I know we can also include the Maven POMs as well. Adding the Jenkinsfile to that would be very interesting.

---

<div class="post-metadata">

**Author:** ![alexander.bohn](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@alexander.bohn](https://community.jenkins.io/u/alexander.bohn)\
**Post date:** [May 8, 2025, 2:07pm UTC](https://community.jenkins.io/t/formatting-jenkins-declarative-pipeline-code/30326/5 "2025-05-08T14:07:06Z")

</div>

Hello Ken and Artalus,

thank you for your responses.
