Try loading your cans dynamically. This is the final working solution I found. This sample is for the network copy folder on the local computer.
def file = new File("jcifs-1.3.18.jar") this.class.classLoader.rootLoader.addURL(file.toURI().toURL()) def auth_server = Class.forName("jcifs.smb.NtlmPasswordAuthentication").newInstance("domain", "username", "password") def auth_local = Class.forName("jcifs.smb.NtlmPasswordAuthentication").newInstance(null, "local_user", "password") def source_url = args[0] def dest_url = args[1] def auth = auth_server //prepare source file if(!source_url.startsWith("\\\\")) { source_url = "\\\\localhost\\"+ source_url.substring(0, 1) + "\$" + source_url.substring(1, source_url.length()); auth = auth_local } source_url = "smb:"+source_url.replace("\\","/"); def source = Class.forName("jcifs.smb.SmbFile").newInstance(source_url,auth_server) //prepare destination file if(!dest_url.startsWith("\\\\")) { dest_url = "\\\\localhost\\"+ dest_url.substring(0, 1) + "\$" +dest_url.substring(2, dest_url.length()); auth = auth_local } dest_url = "smb:"+dest_url.replace("\\","/"); def dest = Class.forName("jcifs.smb.SmbFile").newInstance(dest_url,auth_local) source.copyTo(dest)
source share