How do you get the path of the running script in groovy?

You are correct that new File(".").getCanonicalPath() does not work. That returns the working directory.

To get the script directory

scriptDir = new File(getClass().protectionDomain.codeSource.location.path).parent

To get the script file path

scriptFile = getClass().protectionDomain.codeSource.location.path

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)