shell.build-ope.gradle Maven / Gradle / Ivy
plugins {
id 'org.hidetake.ssh' version '2.9.0'
}
repositories
{
maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
mavenCentral()
jcenter()
}
ext {
jarName='mqtt-api-1.0.jar'
serviceLocation='/data/ly/program/Dev1.Mqtt.Web'
serviceName='mqtt api 服务'
}
dependencies
{
}
ssh.settings {
knownHosts = allowAnyHosts
}
remotes
{
no {
host = '172.18.115.63'
user = 'root'
port= 22
password = '123456'
//identity = identity = file("${System.properties['user.home']}/.ssh/test/id_rsa")
}
no1 {
host = '172.18.115.64'
user = 'root'
port= 22
password = '123456'
//identity = identity = file("${System.properties['user.home']}/.ssh/test/id_rsa")
}
}
task deploy() << {
ssh.run {
for(deployServer in remotes){
String ip=deployServer.host
session(deployServer){
println "正在关闭 $ip 主机 $serviceName 服务..."
//execute " $(cd `dirname $0`; pwd)"
execute "sh $serviceLocation/stop.sh",ignoreError:true
println "删除 主机$ip 目录内容"
execute "rm -fr $serviceLocation",ignoreError: true
println "创建 主机$ip 目录"
execute "mkdir -p $serviceLocation"
println "上传 $jarName 到主机$ip $serviceLocation"
put from: "./",into: "$serviceLocation"
execute "rm -fr $serviceLocation/*.gradle"
execute "chmod +x $serviceLocation/start.sh"
execute "chmod +x $serviceLocation/stop.sh"
println "正在关闭 $ip 主机 $serviceName 服务..."
execute "sh $serviceLocation/start.sh"
execute 'true'
println "$ip $serviceName 系统已经正常启动"
}
}
}
}