Created
April 11, 2017 05:26
-
-
Save asraful/ae051f01dc968f9738d38ca8f1b757d1 to your computer and use it in GitHub Desktop.
Naive way to deploy application to remote server using gradle task named : deploy_dev
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
remotes { | |
web01 { | |
role 'webServers' | |
host = 'host.example.com' | |
user = 'userA' | |
knownHosts = allowAnyHosts | |
identity = file('id_rsa') //id_rsa generated file for authentication | |
} | |
} | |
task deploy_dev << { | |
ssh.run { | |
session(remotes.role('webServers')) { | |
def appServerPath = project.property('dev.appserver.location') + '/bin/' | |
def cd_appServerPath = 'cd ' + appServerPath | |
def webappsPath = project.property('dev.appserver.location') + '/webapps/' | |
def cd_webApps = 'cd ' + webappsPath | |
def shutdownTomcat = cd_appServerPath + ' && ./shutdown.sh' | |
def startTomcat = cd_appServerPath + ' && ./startup.sh' | |
def delete_war_file = cd_webApps + ' && rm -rf app*' | |
execute shutdownTomcat | |
execute delete_war_file | |
put from : project.property('war.location'), into : webappsPath | |
execute startTomcat | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment