public static < T > T executeGroovyShellScript ( final String script , final Map < String , Object > variables , final Class < T > clazz ) { try { val binding = new Binding ( ) ; val shell = new GroovyShell ( binding ) ; if ( variables != null && ! variables . isEmpty ( ) ) { variables . forEach ( binding :: setVariable ) ; } if ( ! binding . hasVariable ( "logger" ) ) { binding . setVariable ( "logger" , LOGGER ) ; } LOGGER . debug ( "Executing groovy script [{}] with variables [{}]" , script , binding . getVariables ( ) ) ; val result = shell . evaluate ( script ) ; return getGroovyScriptExecutionResultOrThrow ( clazz , result ) ; } catch ( final Exception e ) { LOGGER . error ( e . getMessage ( ) , e ) ; } return null ; }
Execute groovy shell script t .