I am a big fan of the new Jenkins Pipeline suite and enjoy defining my pipelines as code. Now, I noticed that there is even a way to make IntelliJ IDEA aware ofthe pipeline DSL syntax, which supports the developer with autocompletion and documentation.
For looking up the DSL syntax, I am a frequent visitor of the Pipeline Steps Reference on jenkins.io. As I am only seldom visiting the Jenkins web interface to use the Pipeline Syntax Snippet Generator, I was a bit puzzled when I stumbled over a mysterious IntelliJ IDEA GDSL link (available for logged-in users).
After reading these words and curiously following the link, my confidence that this would finally help me (still a Groovy novice) to improve my experience of coding with the roovy DSL used by the pipeline plugin. I already used the _Groovy plugin in IntelliJ IDEA, but, of course, all syntax of the Pipeline DSL were unknown until this point.
The content of the text file shown after following the link started with the following lines:
Yes, the known pipeline steps
error, etc. That’s what I need to make IntelliJ aware of. But I had no clue, how to get that into the IDE.
Following the documentation “Scripting IDE for DSL awareness” and this Gist, I figured out that I have to place this “somewhere in the classpath”. Nowhere within the project worked out, however.
My project, is a Pipeline Global Library, which allows to define functionality used in
Jenkinsfiles of multiple projects. The same, however, should apply to projects that only make use of the
After putting the contents of the Jenkins output into a
pipeline.gdsl file in the
src/ folder and importing my project as a new Groovy project into IntelliJ (File > New > Project from Existing Sources…), a message popped up: DSL descriptor file has been change and isn’t currently executed.
Since then, I can enjoy autocompletion as well as well as documentation of the Pipeline DSL.
It is not completely clear to me, why I was not able to achieve that with my existing IntelliJ project. Adding the
src/pipeline.gdsl file did not trigger any message. So probably, the Groovy setup that I had was not 100% correct. During import of the new project, IntelliJ found the two directories contained in my global library.
I hope this helps, either by making you aware of this “feature” or by helping to solve the problem that the
.gdsl file is not picked up.
The problem was, that /src was not marked as a source root folder in my project. Creating a folder /src/main/groovy, putting the file in there and marking it as a sources root (right click on the folder -> Mark directory as -> Sources Root) did the trick.