I recently ran into the problem that a Java library I loaded through grape was obviously hidden by a dependency of the Jira Plugin (Which Jersey version runs in Jenkins 2.107.1?). The possibility of such a conflict is also documented in https://issues.jenkins-ci.org/browse/JENKINS-44378.
This makes me wonder: If my pipeline and the Jenkins plugins live in the same JVM without any separation, I can never know which version of a specific jar/class will be used and it is very difficult to stably run a pipeline.
I can only think of two solutions:
I do not load external libraries through grape, but put some functionality into REST services which I call from the pipeline.
I somehow tell Jenkins to run my pipeline in separation (separate JVM, separate classloader, etc.)
I would prefer (2), but I do not know how to achieve it. Any suggestions?