How do I get the name of the script being executed in Groovy?
It is not a command line argument and hence the args array is not of any help.
You can get the present script name as follows.
def scriptName = this.class.getName()
println "Script FQCN : " + scriptName
It will print out the name of the script (which is nothing but a Class) with its package name - FQCN (Fully Qualified Class Name).
If you want just the script name and NOT the package, you can use
println "Script Simple Name : " + this.class.getSimpleName()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With