Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-32731

Allow plugins to contribute to Pipeline global library

      I'd like to be able to write a plugin that provides an opinionated DSL for Pipeline, behaving like it had been added to the global library, i.e., something like https://github.com/jenkinsci/workflow-examples/tree/master/global-library-examples/global-function but more so. I like the idea of delivering it via a plugin so that it can be tested, versioned, released, etc like any other plugin, but I don't see any way to do this currently. I'd imagine the logical way to do this would be to add the capacity to do this to Pipeline proper, but I could be wrong.

          [JENKINS-32731] Allow plugins to contribute to Pipeline global library

          Jesse Glick added a comment -

          Jesse Glick added a comment - Close try

          Michael Neale added a comment -

          Based on what I have seen, I think there is sufficient ability for plugins to add to a global library already - by providing a GlobalVariable extension. Some intelligence needs to be applied around naming and state, but overall, it works just fine (or can be sugared up). There is no need for plugins to "commit" to the workflowLibs repo - I think that would be not right.

          So I vote we close this in favour of an example/wiki page as "done".

          Michael Neale added a comment - Based on what I have seen, I think there is sufficient ability for plugins to add to a global library already - by providing a GlobalVariable extension. Some intelligence needs to be applied around naming and state, but overall, it works just fine (or can be sugared up). There is no need for plugins to "commit" to the workflowLibs repo - I think that would be not right. So I vote we close this in favour of an example/wiki page as "done".

          Jesse Glick added a comment -

          I think there is sufficient ability for plugins to add to a global library already - by providing a GlobalVariable extension

          …but we still need an API to allow DSLD/GDSL generators to know that a given variable has a type given by a specific Groovy resource, so they could have a chance at offering strong typing. For example, if docker-workflow is installed, you would ideally like IDEA to be able to complete docker.image('maven').ins to inside.

          Jesse Glick added a comment - I think there is sufficient ability for plugins to add to a global library already - by providing a GlobalVariable extension …but we still need an API to allow DSLD/GDSL generators to know that a given variable has a type given by a specific Groovy resource, so they could have a chance at offering strong typing. For example, if docker-workflow is installed, you would ideally like IDEA to be able to complete docker.image('maven').ins to inside .

          Andrew Bayer added a comment -

          +1 - I wonder if we might want to end up doing something with annotations here...

          Andrew Bayer added a comment - +1 - I wonder if we might want to end up doing something with annotations here...

          Jesse Glick added a comment -

          Prefer to avoid annotations unless there is something that cannot be done without them.

          GroovyFileGlobalVariable is a prototype but does not suffice for code completion.

          Jesse Glick added a comment - Prefer to avoid annotations unless there is something that cannot be done without them. GroovyFileGlobalVariable is a prototype but does not suffice for code completion.

          Jesse Glick added a comment - - edited

          Also need to allow the library code to be loaded in trusted mode, which the GlobalVariable API does not currently make straightforward. That would simplify some things; for example DockerDSL.MiscWhitelist could be deleted, and @Whitelisted removed from ImageNameTokens.

          Jesse Glick added a comment - - edited Also need to allow the library code to be loaded in trusted mode, which the GlobalVariable API does not currently make straightforward. That would simplify some things; for example DockerDSL.MiscWhitelist could be deleted, and @Whitelisted removed from ImageNameTokens .

          Jesse Glick added a comment -

          allow the library code to be loaded in trusted mode

          Turns out this already works, as of JENKINS-34650.

          Jesse Glick added a comment - allow the library code to be loaded in trusted mode Turns out this already works, as of JENKINS-34650 .

          Code changed in jenkins
          User: Jesse Glick
          Path:
          pom.xml
          src/main/java/org/jenkinsci/plugins/docker/workflow/DockerDSL.java
          src/main/java/org/jenkinsci/plugins/docker/workflow/ImageNameTokens.java
          http://jenkins-ci.org/commit/docker-workflow-plugin/abe4066b6b4eb1af3e922897add192df4e0294ef
          Log:
          JENKINS-32731 JENKINS-34650 Docker.groovy is already trusted.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/main/java/org/jenkinsci/plugins/docker/workflow/DockerDSL.java src/main/java/org/jenkinsci/plugins/docker/workflow/ImageNameTokens.java http://jenkins-ci.org/commit/docker-workflow-plugin/abe4066b6b4eb1af3e922897add192df4e0294ef Log: JENKINS-32731 JENKINS-34650 Docker.groovy is already trusted.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          pom.xml
          src/main/java/org/jenkinsci/plugins/docker/workflow/DockerDSL.java
          src/main/java/org/jenkinsci/plugins/docker/workflow/ImageNameTokens.java
          src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy
          http://jenkins-ci.org/commit/docker-workflow-plugin/223612bc8378cc3e02cc6fecee1416c5bd533af9
          Log:
          Merge pull request #75 from jglick/GlobalVariable-JENKINS-32731

          JENKINS-32731 JENKINS-34650 Docker.groovy is already trusted

          Compare: https://github.com/jenkinsci/docker-workflow-plugin/compare/1f5f9d0147c4...223612bc8378

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/main/java/org/jenkinsci/plugins/docker/workflow/DockerDSL.java src/main/java/org/jenkinsci/plugins/docker/workflow/ImageNameTokens.java src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy http://jenkins-ci.org/commit/docker-workflow-plugin/223612bc8378cc3e02cc6fecee1416c5bd533af9 Log: Merge pull request #75 from jglick/GlobalVariable- JENKINS-32731 JENKINS-32731 JENKINS-34650 Docker.groovy is already trusted Compare: https://github.com/jenkinsci/docker-workflow-plugin/compare/1f5f9d0147c4...223612bc8378

          Andrew Bayer added a comment -

          The current situation is sufficient, so I'm closing this.

          Andrew Bayer added a comment - The current situation is sufficient, so I'm closing this.

            jglick Jesse Glick
            abayer Andrew Bayer
            Votes:
            3 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: