Search code examples
intellij-ideaautocompletesyntax-highlightingjenkins-groovy

Intellij jenkins pipeline script syntax highlight / autocomplete


I have a file "Jenkinsfile" in a java project, and Intellij-idea 2023.1.4 will automagically do syntax highlighting and even some basic code completion for me (though it doesn't make use of any .gdsl file I have). But ONLY with that filename.

How do I get this behavior with some other filename, and get intellij to use the .gdsl files from jenkins to get code completion?

I'm working on a project with multiple pipelines, all named differently with the .pipeline extension.

What I tried, by order of desperation:

  • Looked up Intellij's help page, no mention of Jenkins at all.
  • Found this stack overflow post , the solution didn't work for me.
  • Found this blog post , but it didn't work for me: I retrieved the .gdsl file from Jenkins and made sure to define the folder with .gdsl files as a source file, but every single method into the .gdsl file gets the error "No candidates found for method call method". I also added the .pipeline to the groovy file association, and it barely makes a difference: I get countless error like "No candidates found for method call node.".
  • Tried to use some other filename without extension.
  • Tried to use filenames that include "Jenkinsfile" at the beginning.

Nothing works. Am I doing something wrong? Did I miss something?

And again, it has nothing to do with the content of my pipeline scripts themselves, as everything works perfectly when their content is copy-pasted into the file named "Jenkinsfile".


Solution

  • After contacting Intellij support:

    "The completion, highlighting, and other features for the Jenkinsfile are provided by the Groovy TextMate bundle functionality. Unfortunately, there is no option for now to specify another custom file type to be recognized the same way as Jenkinsfile.

    We have several feature requests regarding the problem in our YouTrack, for example, this one I'd recommend you upvote it to show your interest"

    So, I guess I am currently out of luck, this feature simply doesn't exist in Intellij IDEA at this point in time. I'll just edit my jenkins pipeline scripts, within the file "Jenkinsfile" for now.