Last active
August 29, 2015 14:05
-
-
Save int128/4a47631f55e7e2efeb78 to your computer and use it in GitHub Desktop.
Specification of Gradle SSH Plugin and Groovy SSH Library (work in progress)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath 'org.hidetake:gradle-ssh-plugin:0.4.0' | |
} | |
} | |
apply plugin: 'ssh' | |
// Global settings | |
ssh.settings { | |
identity = file('id_rsa') // Enable public key authentication | |
knownHosts = allowAnyHosts // Disable host key verification | |
} | |
// Add a remote host | |
ssh.remotes { | |
webServer { | |
host = '192.168.1.101' | |
user = 'jenkins' | |
} | |
} | |
task deploy(dependsOn: war) << { | |
ssh.run { | |
settings { | |
// Enable PTY allocation for sudo | |
pty = true | |
} | |
session(ssh.remotes.webServer) { | |
// Put a built WAR to the server | |
put war.archivePath, '/webapps' | |
// Restart the application server | |
execute 'sudo service tomcat restart' | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab(group='org.hidetake', module='groovy-ssh', version='0.1.0') | |
import static org.hidetake.groovy.ssh.Ssh.* | |
// Global settings | |
ssh.settings { | |
identity = new File('id_rsa') // Enable public key authentication | |
knownHosts = allowAnyHosts // Disable host key verification | |
} | |
// Add a remote host | |
ssh.remotes { | |
webServer { | |
host = '192.168.1.101' | |
user = 'jenkins' | |
} | |
} | |
ssh.run { | |
settings { | |
// Enable PTY allocation for sudo | |
pty = true | |
} | |
session(ssh.remotes.webServer) { | |
// Put a built WAR to the server | |
put 'example.war', '/webapps' | |
// Restart the application server | |
execute 'sudo service tomcat restart' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment