• Declarative - 1.2

        [JENKINS-40127] Declarative Pipeline GDSL

        Is this still on the roadmap? It's kind of an obvious gap

        Forrest Hopkins added a comment - Is this still on the roadmap? It's kind of an obvious gap

        Federico Naum added a comment - - edited

        Federico Naum added a comment - - edited hey gijsl I'm not 100% sure, but I think this is the piece of code that generates the GDSL https://github.com/jenkinsci/workflow-cps-plugin/blob/4fc3310d5e056cc8bee340b91e5c87a989756923/src/main/resources/org/jenkinsci/plugins/workflow/cps/Snippetizer/gdsl.groovy  

        Moritz P added a comment -

        Is there some plan to do this?

        Moritz P added a comment - Is there some plan to do this?

        Oleg Nenashev added a comment -

        I'd guess we need to ask abayer

        Oleg Nenashev added a comment - I'd guess we need to ask abayer

        Disclaimer: I'm not by any chance a GDSL/Jenkins/Pipeline/Java/Groovy expert

        Using a bit of common sense and a lot of Google/copy paste I was able to generate the following script that supports declarative pipelines as to the knowledge that I currently have:

        https://gist.github.com/ggarcia24/fc5acec3288812b34c64a4f2b8f9bca9

        Hoping to get a little bit of feedback and then perhaps create a PR using the code from the file posted above to generate a new one. Hope it can help someone

        Gonzalo G.

        Gonzalo Garcia added a comment - Disclaimer: I'm not by any chance a GDSL/Jenkins/Pipeline/Java/Groovy expert Using a bit of common sense and a lot of Google/copy paste I was able to generate the following script that supports declarative pipelines as to the knowledge that I currently have: https://gist.github.com/ggarcia24/fc5acec3288812b34c64a4f2b8f9bca9 Hoping to get a little bit of feedback and then perhaps create a PR using the code from the file posted above to generate a new one. Hope it can help someone Gonzalo G.

        James Howe added a comment -

        ggarcia24 if you have code that generates the GSDL please share it. The result will be different for every Jenkins instance depending on what plugins (and versions thereof) are installed.

        James Howe added a comment - ggarcia24 if you have code that generates the GSDL please share it. The result will be different for every Jenkins instance depending on what plugins (and versions thereof) are installed.

        Joachim Hagege added a comment - - edited

        Any news on this ? 
        Would be lovely to have support in IntelliJ IDEA of pipeline syntax !

        Joachim Hagege added a comment - - edited Any news on this ?  Would be lovely to have support in IntelliJ IDEA of pipeline syntax !

        Jozsef Pohl added a comment -

        Some update on this topic: I tried to use the gdsl file created by ggarcia24, and also checked a fork. Although it is possible to add support for every plugin, I could not find a way to support some parts of the basic pipeline structure.

        For example gdsl alone is not enough for the IDE to properly identify global variables and shared libraries. I suppose the whole jenkins library has to be linked inside the project somehow. Also the agent any expression will always be rejected by the IDE since it interprets the any word as a method, not a parameter. Finally I could not find out how to handle the typed parameters like enums (eg. changeRequest comparator) or time units (java.util.concurrent.TimeUnit). Not to mention some tiny details like order and max number of sections/directives.

        Based on these, I think it is impossible to create a gdsl for full IDE awareness of the declarative pipeline. It can improve the UX for some extent, but will never help with the most trivial syntactic issues. However a different approach could solve this problem. The best would be to change the declarative syntax for more strict logic (like yaml), and investigate the new linting possibilities. The other way is to improve the REST validation endpoint in Jenkins to report with more useful messages.

        Jozsef Pohl added a comment - Some update on this topic: I tried to use the gdsl file created by ggarcia24 , and also checked a fork . Although it is possible to add support for every plugin , I could not find a way to support some parts of the basic pipeline structure . For example gdsl alone is not enough for the IDE to properly identify global variables and shared libraries. I suppose the whole jenkins library has to be linked inside the project somehow. Also the agent any expression will always be rejected by the IDE since it interprets the any word as a method, not a parameter. Finally I could not find out how to handle the typed parameters like enums (eg. changeRequest comparator) or time units (java.util.concurrent.TimeUnit). Not to mention some tiny details like order and max number of sections/directives. Based on these, I think it is impossible to create a gdsl for full IDE awareness of the declarative pipeline . It can improve the UX for some extent, but will never help with the most trivial syntactic issues. However a different approach could solve this problem. The best would be to change the declarative syntax for more strict logic ( like yaml ), and investigate the new linting possibilities. The other way is to improve the REST validation endpoint in Jenkins to report with more useful messages.

        Max Calderoni added a comment - - edited

        Also looking forward to news on this.

        Or perhaps some instructions somewhere on how to properly set up your IDE for developing pipelines, including libraries, for what can be done now (I wonder why this has not already been supported for a long time, being Jenkins so popular...).

        So far, I found, among other things, these two sources, one describing how to set up Intellij using gradle, and one comment by jameshowe in gitter describing how to set up the linter.

        Finally, jenkinsfile-runner should be included in an IDE setup so that pipelines can also be run from the IDE.

        Max Calderoni added a comment - - edited Also looking forward to news on this. Or perhaps some instructions somewhere on how to properly set up your IDE for developing pipelines, including libraries, for what can be done now (I wonder why this has not already been supported for a long time, being Jenkins so popular...). So far, I found, among other things, these two sources, one describing how to set up Intellij using gradle , and one comment by jameshowe in gitter describing how to set up the linter. Finally, jenkinsfile-runner should be included in an IDE setup so that pipelines can also be run from the IDE.

        James Howe added a comment -

        Just to note RE that comment, the IDEA plugin was updated and now works fine.

        James Howe added a comment - Just to note RE that comment, the IDEA plugin was updated and now works fine.

          rsandell rsandell
          abayer Andrew Bayer
          Votes:
          87 Vote for this issue
          Watchers:
          61 Start watching this issue

            Created:
            Updated: