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

Extend cps interface so plugins can que additional Steps.

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major Major
    • workflow-cps-plugin
    • None

      I'm building a Plugin in Jenkins that provides an API for scripts that are started from a pipeline-script to independently communicate with jenkins. For example a shell-script can then tell jenkins to start a new stage from the running script.

      After getting the communication between the plugin and the script working with Unix Domain Sockets, I wanted to start a stage from an exported callback proxy. Here is where I've hit a brick wall. I was unable to hook into life cycle and inject a new StageStep in any way I could think of. This SO issue demonstrates my stuggles: https://stackoverflow.com/q/58409878/3968618
      So finally I've got it to work with reflection (see the answer), but as you can tell, it's hacky as hell.

      This issue is a request to provide an interface to safely inject a new step by name. Basically a way to simply call DSL.invokeStep(sd, args) from inside a step/callback.
      I understand this is not the intentional usage, and you might feel the request is hacky in and of itself. But I have been thinking about building a way for scripts to asynchronously communicate with jenkins for some time now, and feel it would be a very good way to make calling things like shell scripts from a pipeline much more powerful, useful and extendable. If my company will allows this, I am planning to make the plugin publicly available for anyone to use.

          [JENKINS-59823] Extend cps interface so plugins can que additional Steps.

          I'm also developing a very complex plugin. At first it was a shared library but I faced with a lot of backward compatibility issues with product, for example tracking hardware available for e2e testing. So I've decided to move this huge system into Jenkins plugin and share this with people. It will be very useful for embedded solutions.

          The problem is that there is no way to execute external steps from my plugin. For example, I want to use Jenkins step sshCommand inside my plugin to execute command on server inside lab. Writing SSH implementation on Java myself is a big effort. Especially, when I also need steps like archiveArtiffacts, sh, publishHTML, parallel, etc...

          Are there plans to implement this?

          Vladyslav Kovalov added a comment - I'm also developing a very complex plugin. At first it was a shared library but I faced with a lot of backward compatibility issues with product, for example tracking hardware available for e2e testing. So I've decided to move this huge system into Jenkins plugin and share this with people. It will be very useful for embedded solutions. The problem is that there is no way to execute external steps from my plugin. For example, I want to use Jenkins step sshCommand inside my plugin to execute command on server inside lab. Writing SSH implementation on Java myself is a big effort. Especially, when I also need steps like archiveArtiffacts, sh, publishHTML, parallel, etc... Are there plans to implement this?

            Unassigned Unassigned
            exturo Leon Moll
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: