Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode and Jenkinsfiles. How do I format them?

I want to fix formatting in Jenkinsfiles in VSCode 'Shift-Alt F' gives me "There is no formatter for 'groovy' files installed" and pops open an extensions sidebar with no relevant extensions that help do the formatting.

How can I format my files. Thanks. I have 'Jenkinsfile Support' and 'cod-groovy' installed. Still no dice.

Thanks.

like image 931
David West Avatar asked May 15 '19 13:05

David West


1 Answers

You can use this extension https://marketplace.visualstudio.com/items?itemName=ivory-lab.jenkinsfile-support called JenkinsFile Support.

And also use the workaround defined here (using the files.associations option of VSCode) to give linting for any file with the Jenkinsfile string in the filename https://github.com/sgwozdz/jenkinsfile-support/issues/62#issuecomment-829353453

    "files.associations": {
        "[Jj]enkinsfile*": "jenkinsfile"
    }

If you don't want to use external extensions, you can use the groovy Id in your settings (just remember, Groovy is not one to one to Jenkinsfiles)

    "files.associations": {
        "[Jj]enkinsfile*": "groovy"
    }
like image 164
julian-alarcon Avatar answered Sep 18 '22 17:09

julian-alarcon