Skip to content

Instantly share code, notes, and snippets.

@asraful
Created April 11, 2017 05:26
Show Gist options
  • Save asraful/ae051f01dc968f9738d38ca8f1b757d1 to your computer and use it in GitHub Desktop.
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
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