Jenkinsfile syntax highlighting in PyCharm Idea
The following filetype xml will highlight Jenkinsfile syntax in PyCharm
create a new Jenkinsfile.xml
, copy the following xml:
<filetype binary="false" description="Jenkinsfile support" name="Jenkinsfile"> <highlighting> <options> <option name="LINE_COMMENT" value="//" /> <option name="COMMENT_START" value="/*" /> <option name="COMMENT_END" value="*/" /> <option name="HEX_PREFIX" value="" /> <option name="NUM_POSTFIXES" value="" /> <option name="HAS_BRACES" value="true" /> <option name="HAS_BRACKETS" value="true" /> <option name="HAS_PARENS" value="true" /> <option name="HAS_STRING_ESCAPES" value="true" /> <option name="LINE_COMMENT_AT_START" value="true" /> </options> <keywords keywords="def;else;if;import;print;return" ignore_case="true" /> <keywords2 keywords="node" /> <keywords3 keywords="field;library;stage;string" /> <keywords4 keywords="try;catch;finally" /> </highlighting> <extensionMap> <mapping pattern="Jenkinsfile" /> </extensionMap></filetype>
and place it under
macOS
~/Library/Preferences/PyCharmXX/filetypes
Linux copy to
/.PyCharmXX/config/filetypes
Win copy to
<User home>\.PyCharmXX\config\filetypes
~~Unfortunately, Pycharm does not currently support Groovy/Jenkinsfile syntax highlighting.~~
UPDATE: Please see the other answers on this thread to check if groovy support is discovered or added for PyCharm.
While this does not officially answer your question it does provide a workaround for those who are interested.
Install IntelliJ IDEA, the community edition can be downloaded free from intelliJ
Once installed, open File-->Settings-->Editor-->File Types-->Groovy and you can associate Jenkinsfile with the Groovy syntax by adding 'Jenkinsfile*' to the Groovy 'Registered patterns':
A word to the wise: Don't open the Jenkinsfile directly in your Pycharm project with IDEA. It will start writing to the '.idea' folder and cause conflicts with the pyCharm IDE. I like to symlink/softlink my Jenkinsfile into a subdirectory of a folder called 'jenkinsfiles'. So if I have a project called ProjectA I symlink the Jenkins file to ..path../jenkinsfiles/ProjectA/Jenkinsfile. I then open ..path../jenkinsfiles/ in IDEA and can manage all the Jenkinsfiles for all my projects from there.
UPDATE: lately I have been enjoying the free https://code.visualstudio.com/ which has a groovy plugin https://marketplace.visualstudio.com/items?itemName=marlon407.code-groovy.
It's possible. We can add groovy TextMate bundle to PyCharm. Unfortunately PR for Jenkinsfile
support waiting for a long time, so we need to do some changes in packet manually.
- Download and unpack https://github.com/textmate/groovy.tmbundle/archive/master.zip
- open
path_to_unpacked_package/Groovy.tmLanguage
file in editor and add<string>Jenkinsfile</string>
after line<string>gvy</string>
- Open PyCharm->Settings->TextMate Bundles and add modified
groovy.tmbundle
Based on this answer and tested on PyCharm 2019.1.2 Pro
P.S. As alternative one can use this fork without any modifications
P.P.S. from @jeff-welling comment: If you have no TextMate Bundles
in setup, then follow this instruction to install it
Pycharm 2019.2 changelog: PyCharm will now highlight the syntax of Windows .bat files, C#, C++, Groovy, Lua, Makefiles, and more