Jenkinsfile syntax highlighting in PyCharm Idea

Anthony Martin picture Anthony Martin · Jul 1, 2018 · Viewed 10.8k times · Source

I've been looking an so far have been unable to find any way of enabling syntax highlighting for jenkinsfile in PyCharm. Does anyone know of a method to do this? I am specifically using scripted pipeline.

Answer

gCoh picture gCoh · Jun 25, 2019

The following filetype xml will highlight Jenkinsfile syntax in PyCharm

JFHighlight

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

https://github.com/galCohen88/pycharm-jenkinsfile