hudson用SVN插件下载代码,用ant插件打包, 用SSH插件部署

hudson自动化部署步骤

1、SVN插件->下载代码

2、ant插件->war打包    (hudson服务器上可安装多个版本ant,每个项目可以选择一个ant版本。Build File:填写build.xml构建脚本路径)

3、SSH插件->shell脚本部署,重启tomcat

4、SSH插件讲解

4.1、远程服务器配置
SSH Servers name : xxxx
           host:192.168.0.2
           user:root
           remote directory: /usr/local (系统设置的远程服务器顶级目录)

4.2、部署war包传输和tomcat重启

Send build artifacts over SSH        #通过SSH传war包

SSH Servers name : xxxx              #远程服务器
                   Transfers->Source files: sso/product/sso/test/sso.war    # (本地服务器)
                   Remote directory: wars     # (远程服务器,实际为/usr/local/wars)
                   Exec command : kill -9 `ps aux|grep tomcat1 |grep -v grep |grep java |awk '{print $2}'`   #(杀tomcat进程)
                     cp /usr/local/wars/sso/product/sso/test/sso.war /usr/local/tomcat1/webapps/   #(war包复制,现在同机复制,但通常跨服务器复制)
                     /usr/local/tomcat1/bin/startup.sh     #(重启tomcat,可写个脚本)

总结:

hudson使用SVN插件下载代码。使用下载下来的源代码,用ant插件进行打war包,war包位置在ant的build.xml脚本定义。

最后使用SSH插件将war包传到远程端的应用服务器,然后在远程应用服务器解压war包启动tomcat,部署完毕。

原文地址:https://www.cnblogs.com/chenweichu/p/7236615.html