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?
Groovy Lint uses CodeNarc 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. 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, there are some Groovy plugins for it – but they are in various state of disarray.
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.