I have a Jenkins Pipeline project which loads several Groovy scripts. When I run this pipeline, Jenkins names these scripts' classes Script1, Script2, and so on. These names are displayed when replaying a build. They also appear on exception stack traces. I find this confusing, especially when there is more than a couple of scripts.
Is there any way of setting these names from the pipeline or -preferably- from within the scripts themselves? So far I tried manipulating the scripts' metaClass:
this.metaClass.name = 'Foo' //fails, doesn't find metaClass property
this.class.metaClass.name = 'Foo' //doesn't fail but has no apparent effect
this.class.metaClass.simpleName = 'Foo' //idem
this.class.metaClass.canonicalName = 'Foo' //idem
NOTE: I am well aware of Jenkins shared libraries. This question is meant to focus on loaded scripts alone.