ssh plugin

org.hidetake.ssh

Gradle SSH Plugin is a Gradle plugin which provides remote command execution and file transfer features.

https://gradle-ssh-plugin.github.ioarrow-up-right

远程部署插件, 可以远程传输文件,也可以执行远程shell命令

配置build.gradle文件

插件官方网址https://gradle-ssh-plugin.github.io/arrow-up-right

gradle插件https://plugins.gradle.org/plugin/org.hidetake.ssharrow-up-right

//引入插件,此插件依赖war插件
plugins {
    id 'war'
    id 'org.hidetake.ssh' version '2.9.0'
}
//远程服务器信息
remotes {
  webServer {
    host = '172.18.112.102'
    user = 'root'
    password = 'lingyi2016'
  }
}
//创建远程部署任务
task deployT(dependsOn: war) << {
    ssh.run {
        session(remotes.webServer) {
            put from: war.archivePath.path, into: '/opt/test/apache-tomcat-8.5.15/webapps'
            execute "service tomcat restart"
        }
    }
}

执行下面的命令即可

配置tomcat服务

linux服务器上配置tomcat以service方式启动

http://blog.csdn.net/chen_pt/article/details/53139488arrow-up-right

  1. 在/etc/init.d目录下新建文件,命名为tomcat

  2. 对tomcat文件进行编辑,执行

将下面代码粘上去

注意:下面代码java_home和catalina_home是指jdk和tomcat安装的根路径

  1. 按ESC退出,并#:wq

  2. 设置tomcat的文件属性,把tomcat 修改为可运行的文件,命令参考如下

  1. 设置服务运行级别

  1. 服务就添加成功了

然后用 chkconfig --list 查看,在服务列表里就会出现自定义的服务了

  1. 测试

​​​​​​​​​​​​

Last updated

Was this helpful?