Aali M
Aali M

Reputation: 113

How to format Jenkinsfile locally?

I want to format Jenkinsfile locally and understand if they are any formatting issues. I use sublime editor for editing. Is there a better editor which can also suggest me any formatting errors? I do not want to use any online formatting tools.

Upvotes: 8

Views: 33489

Answers (2)

Fluffy Panda
Fluffy Panda

Reputation: 69

I use VSCode and a Jenkinsfile. In order to format it, I use a popular Groovy code formatter extension, but first I must rename the Jenkinsfile to Jenkinsfile.groovy. I reformat it, then save it back to the original filename (without the .groovy extension).

Upvotes: 0

Karol Dowbecki
Karol Dowbecki

Reputation: 44970

IntelliJ can be configured to parse Jenkinsfile as a regular Groovy file, as explained in this question or this article. This allows to use standard Groovy formatting and syntax check.

However, you might want to consider using Replay Pipeline functionality in your Jenkins instance instead.

Upvotes: 5

Related Questions