jenkins可以将一个war包通过“Deploy war/ear to a container” 插件发送到远程的tomcat容器里
之前,曾经用这个方法发布应用,这里记录一下,以部署nhorizons-webapp-protostar为例
1. jenkins安装插件
2 前面的参考:https://www.cnblogs.com/bloodthirsty/p/11344891.html,执行shell时修改
#!/bin/bash BUILD_ID=DONTKILLME echo "start execute shell" cd $WORKSPACE/nhorizons-application mvn clean install cd $WORKSPACE/nhorizons-application/nhorizons-webapp-base mvn clean install cd $WORKSPACE/nhorizons-application/$appName mvn clean package -Ptest
3 构建后操作
4 关于tomcat7在linux上的安装
cd /usr/local/
wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.96/bin/apache-tomcat-7.0.96.tar.gz
tar -zxvf apache-tomcat-7.0.96.tar.gz
vi apache-tomcat-7.0.96/conf/tomcat-users.xml
增加用户:
<role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <user username="tomcat" password="xxx" roles="manager-gui,manager-script,manager-jmx,manager-status"/> <user username="deploy" password="xxxxx" roles="manager-gui,manager-script,manager-jmx,manager-status"/>
修改端口:
找到
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
修改8080为你的端口
cd apache-tomcat-7.0.96
./bin/start.sh
5 Context path
为什么不用它?部署后发现,用http://ip:your port/context path/login.htm登录,
而我的项目里是用tomcat7-maven-plugin启动的,所以弃用,改用clean tomcat7:run