Use Reflection in Jenkins Pipeline
Jenkins Pipeline's class loading is different from the normal Java class loading. It has its own designed class loading within the plugins.
Here is the official introduction dependencies-and-class-loading.
Briefly, if we want to use reflection to dynamic load class defined in pipeline, we need to use Thread
.currentThread().getContextClassLoader()
.