Skip to content

Instantly share code, notes, and snippets.

@raymyers
Last active July 12, 2022 12:30
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save raymyers/5987574 to your computer and use it in GitHub Desktop.
Save raymyers/5987574 to your computer and use it in GitHub Desktop.
apply plugin: 'java'
apply plugin : 'war'
group = 'com.cadrlife'
version = '1.0.0'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.hidetake:gradle-ssh-plugin:0.1.7'
}
}
apply plugin: 'ssh'
remotes {
web01 {
host = '192.xxx.x.x'
user = 'deployuser'
// password = 'pass'
identity = file('ident.pem')
}
}
ssh {
config(StrictHostKeyChecking: 'no') // needed for deploying to EC2
}
task deployWar(type: SshTask, dependsOn: 'war') {
def tomcatHome = '/usr/share/tomcat7/webapps'
def warName = "ROOT"
session(remotes.web01) {
println "Uploading new war"
put(war.archivePath.absolutePath,"${tomcatHome}/${warName}.war.new")
println "removing old war"
execute("rm ${tomcatHome}/${warName}.war")
println "activating new war"
execute("mv ${tomcatHome}/${warName}.war{.new,}")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment