Gradle SSH

Ant sshexec, scp

configurations {
    sshAntTask
}
 
dependencies {
    sshAntTask 'org.apache.ant:ant-jsch:1.9.4', 'com.jcraft:jsch:0.1.51'
}
 
ant.taskdef(name: 'scp',
        classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp',
        classpath: configurations.sshAntTask.asPath)
 
ant.taskdef(name: 'sshexec',
        classname: 'org.apache.tools.ant.taskdefs.optional.ssh.SSHExec',
        classpath: configurations.sshAntTask.asPath)
 
// SCP
ant.scp(file: "file-to-transfer.zip",
    todir: 'kwon37xi@hostname:/home/kwon37xi/dir',
    keyfile: '${user.home}/.ssh/id_rsa', // ${user.home}은 ant 변수임. 홑따옴표주의!
    passphrase: 'passphrase',
    verbose: true)
 
// SSHEXEC
ant.sshexec(
    host: 'hostname',
    username: 'kwon37xi',
    trust: 'true',
    keyfile: '${user.home}/.ssh/id_rsa', // ${user.home}은 ant 변수임. 홑따옴표주의!
    passphrase: 'passphrase',
    verbose: true,
    command: "ls -la /usr/bin"
)