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.