增加自动化功能
- 增加hook ,码云master分支一点发生变动,就自动构建
- 构建后自动推送到tomcat服务器,完成部署,重启tomcat
准备工作
- 新建一个centos6.5服务器,用于项目tomcat发布。
- 将两台服务器进行
ssh 免密码登录
开始
-
安装远程部署插件
Deploy to container Plugin
-
在项目中设置,构建后的操作为部署war到容器
这里需要进行设置的是远程Tomcat的管理员信息,修改远程Tomcat容器下的conf 下的 tomcat-users.xml文件,在内添加下边的内容
<role rolename="manager"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="admin"/>
<user username="admin" password="admin" roles="admin,manager,manager-script,manager-gui"/>
- 将wx2主机tomcat
<tomcat>/webapps/manager/META-INF/context.xml
访问IP限制注释掉
<Context antiResourceLocking="false" privileged="true" >
<!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
</Context>
- 配置远程tomcat 配置地址 http://wx2:8080 图上多了个/
- 开始构建,远程部署成功
[INFO] Installing /root/.jenkins/workspace/eova/pom.xml to /root/.m2/repository/com/zaxl/zaxl/1.0.1-SNAPSHOT/zaxl-1.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.258 s
[INFO] Finished at: 2018-01-25T17:49:11+08:00
[INFO] Final Memory: 31M/76M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /root/.jenkins/workspace/eova/pom.xml to com.zaxl/zaxl/1.0.1-SNAPSHOT/zaxl-1.0.1-SNAPSHOT.pom
[JENKINS] Archiving /root/.jenkins/workspace/eova/target/zaxl.war to com.zaxl/zaxl/1.0.1-SNAPSHOT/zaxl-1.0.1-SNAPSHOT.war
channel stopped
[eova] $ /bin/sh -xe /root/Program/apache-tomcat-8.5.11/temp/jenkins7151441205460350046.sh
Deploying /root/.jenkins/workspace/eova/target/zaxl.war to container Tomcat 8.x Remote with context
[/root/.jenkins/workspace/eova/target/zaxl.war] is not deployed. Doing a fresh deployment.
Deploying [/root/.jenkins/workspace/eova/target/zaxl.war]
Finished: SUCCESS