사용자 도구

사이트 도구


gradle:ssh

문서의 이전 판입니다!


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
// ${user.home}은 ant 변수임. 홑따옴표주의!
ant.scp(file: "file-to-transfer.zip",
    todir: 'kwon37xi@hostname:/home/kwon37xi/dir',
    keyfile: '${user.home}/.ssh/id_rsa',
    passphrase: 'passphrase',
    verbose: true)
 
// SSHEXEC
ant.sshexec(
    host: 'hostname',
    username: 'kwon37xi',
    trust: 'true',
    keyfile: '${user.home}/.ssh/id_rsa,
    passphrase: 'passphrase',
    verbose: true,
    command: "ls -la /usr/bin"
)
  • 명령 실행결과를 ant.properties에 저장할 수 있다. outputproperty: 'outputPropertyName' 처럼 값을 저장하면, 그 결과를 ant.properties.outputPropertyName 으로 접근 가능해진다.
gradle/ssh.1403863437.txt.gz · 마지막으로 수정됨: 2014/06/27 19:03 저자 kwon37xi