import com.jcraft.jsch.Channel
import com.jcraft.jsch.ChannelSftp
import com.jcraft.jsch.JSch
import com.jcraft.jsch.Session
import com.jcraft.jsch.UserInfo
public void syncLogs(hostname, username, password, port, remoteFile, localFile)
{
println "sync file " + remoteFile + " from server " + hostname
JSch jsch = new JSch()
Session session = jsch.getSession(username, hostname, port)
session.setPassword(password)
def config = new Properties()
config.put("StrictHostKeyChecking", "no")
session.setConfig(config)
session.connect()
Channel channel = session.openChannel("sftp")
channel.connect()
ChannelSftp c = (ChannelSftp)channel
c.get(remoteFile, localFile)
//c.put(localFile, remoteFile)
session.disconnect()
}