Last active
July 12, 2022 12:30
-
-
Save raymyers/5987574 to your computer and use it in GitHub Desktop.
This file contains 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
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