Jenkins Pipeline Autocompletion in IntelliJ

How to make Jetbrains IntelliJ aware of the Jenkinsfile Groovy DSL

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 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).

Jenkins with link to the IntelliJ IDEA GDSL file

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:

//The global script scope
def ctx = context(scope: scriptScope())
contributor(ctx) {
method(name: 'build', type: 'Object', ...
method(name: 'build', type: 'Object', ...
method(name: 'echo', type: 'Object', params: [message:'java.lang.String'], doc: 'Print Message')
method(name: 'error', type: 'Object', params: [message:'java.lang.String'], doc: 'Error signal')
method(name: 'input', type: 'Object', params: [message:'java.lang.String'], doc: 'Wait for interactive input')

Yes, the known pipeline steps build, echo, 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 Jenkinsfile.

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.

message that DSL descriptor file is found

Since then, I can enjoy autocompletion as well as well as documentation of the Pipeline DSL.

autocompletion documentation

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.

message that DSL descriptor file is found

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.

EDIT January, 13th: Michael Lihs figured out one more caveat on StackOverflow (quoting his answer):

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.