Created
December 6, 2012 23:50
-
-
Save mattkasa/4229502 to your computer and use it in GitHub Desktop.
Grails deploy script
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
includeTargets << grailsScript("Init") << grailsScript("War") | |
target(deployWar: "Deploy the project WAR.") { | |
depends(war) | |
println "Starting WAR deployment ..." | |
def warFile = new File(warName) | |
def warFileName = warFile.getName() | |
def webappName = "app" | |
def webappPath = "/usr/share/apache-tomcat-6.0.24/webapps" | |
switch(grailsEnv) { | |
case 'development': | |
Ant.sequential { | |
exec(executable:"scp") { | |
arg(value:"${warName}") | |
arg(value:"dev.host:~/") | |
} | |
exec(executable:"ssh") { | |
arg(value:"dev.host") | |
arg(value:"sudo cp ~/${warFileName} ${webappPath}/${webappName}.war") | |
} | |
} | |
println "Completed WAR deployment to ${grailsEnv}" | |
break | |
case 'production': | |
Ant.sequential { | |
exec(executable:"scp") { | |
arg(value:"${warName}") | |
arg(value:"dev.host:~/") | |
} | |
exec(executable:"ssh") { | |
arg(value:"dev.host") | |
arg(value:"sudo cp ${webappPath}/${webappName}.war ${webappPath}/${webappName}.war.bak") | |
} | |
exec(executable:"ssh") { | |
arg(value:"dev.host") | |
arg(value:"sudo cp ~/${warFileName} ${webappPath}/${webappName}.war") | |
} | |
} | |
println "Completed WAR deployment to ${grailsEnv}" | |
break | |
default: | |
println "Deploy war called in unsupported environment: ${grailsEnv}" | |
break | |
} | |
} | |
setDefaultTarget(deployWar) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment