36

I have a file pipeline.gdsl that contains the Syntax for my Jenkins Pipeline DSL. Following this blog post I put the file into the /src folder of my Java project. When I now edit my Jenkinsfile (residing in the root folder of my project), I don't get any code completion / syntax explanation as I would expect.

My project is a Java / Gradle project and I cannot make a Groovy project out of it. Is there some other way to make IntelliJ aware of the .gdsl file and provide code completion?

1 Answer 1

32

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.

9
  • 1
    How does one do this in Android studio? The Mark Directory As option seems to be issing.
    – Aphex
    Commented Jan 17, 2017 at 21:12
  • 9
    Note: I also had to associate the Jenkinsfile as a Groovy file type using IntelliJ's preferences: imgur.com/a/EWATV
    – nerdherd
    Commented Mar 14, 2017 at 20:43
  • 3
    Do you get the warning 'node' cannot be applied to '(groovy.lang.Closure<Object>)'?
    – lanoxx
    Commented Nov 2, 2017 at 11:54
  • @lanoxx same problem here.
    – Bob Gregor
    Commented Nov 3, 2017 at 18:50
  • 1
    This is not working for me, even with a simple project with just a pipeline.gdsl and a Jenkins file. 'node', 'ws' 'stage', etc ... are not resolved. I have groovy installed on my computer, GROOVY_HOME exists, groovy path to bin is added to PATH, the folder is declared as source folder. However it is a groovy project, not a java one.
    – Milan
    Commented May 14, 2019 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.