参考
###基本环境准备 1、服务器A(192.168.9.1)搭建私服Nexus Repository Manager OSS,其版本号2.13.0-01:
2、服务器B(192.168.9.2)搭建Jenkins,其版本号1.638: 3、jenkins安装插件TestNG Results Plugin 4、服务器B上部署maven、版本号3.3.9,其中maven中mirror指向服务器A搭建的私服地址 5、服务器B上/etc/hosts中配置项192.168.9.1 www.mycompany.com
6、服务器C(192.168.9.3)参考如下博客搭建mysql、redis 、rabbitmq,另外参考官方文档搭建activemq5.13.1。
7、准备服务器D(192.168.9.4)用来部署demo-Rest、demo-Web和demo-Batch,服务器D上部署jdk1.7.0_75,tomcat8.0.35
8、服务器D上/etc/hosts中配置项192.168.9.3 mysqlhost192.168.9.3 rabbitmqhost192.168.9.3 activemqhost192.168.9.3 redishost
9、参考如下博客对服务器B配置免登陆ssh到服务器D
###jenkins中配置ciHelper,deploy到私服,截图如下
执行该任务,输出如下[INFO] Reactor Summary:[INFO] [INFO] cihelper-parent .................................... SUCCESS [ 1.192 s][INFO] base-test .......................................... SUCCESS [ 3.801 s][INFO] base-common ........................................ SUCCESS [ 3.315 s][INFO] MybatisEx .......................................... SUCCESS [ 1.637 s][INFO] thirdparty ......................................... SUCCESS [ 1.855 s][INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 13.762 s[INFO] Finished at: 2016-08-21T22:06:08+08:00[INFO] Final Memory: 27M/167M[INFO] ------------------------------------------------------------------------[JENKINS] Archiving /root/.jenkins/workspace/ciHelper1.1/base-test/pom.xml to com.fastjrun.share/base-test/1.1/base-test-1.1.pom[JENKINS] Archiving /root/.jenkins/workspace/ciHelper1.1/base-test/target/base-test-1.1.jar to com.fastjrun.share/base-test/1.1/base-test-1.1.jar[JENKINS] Archiving /root/.jenkins/workspace/ciHelper1.1/base-test/target/base-test-1.1-sources.jar to com.fastjrun.share/base-test/1.1/base-test-1.1-sources.jar[JENKINS] Archiving /root/.jenkins/workspace/ciHelper1.1/pom.xml to com.fastjrun.share/cihelper-parent/1.1/cihelper-parent-1.1.pom[JENKINS] Archiving /root/.jenkins/workspace/ciHelper1.1/thirdparty/pom.xml to com.fastjrun/thirdparty/1.1/thirdparty-1.1.pom[JENKINS] Archiving /root/.jenkins/workspace/ciHelper1.1/thirdparty/target/thirdparty.jar to com.fastjrun/thirdparty/1.1/thirdparty-1.1.jar[JENKINS] Archiving /root/.jenkins/workspace/ciHelper1.1/MybatisEx/pom.xml to com.fastjrun/MybatisEx/1.1/MybatisEx-1.1.pom[JENKINS] Archiving /root/.jenkins/workspace/ciHelper1.1/MybatisEx/target/MybatisEx-1.1.jar to com.fastjrun/MybatisEx/1.1/MybatisEx-1.1.jar[JENKINS] Archiving /root/.jenkins/workspace/ciHelper1.1/MybatisEx/target/MybatisEx-1.1-sources.jar to com.fastjrun/MybatisEx/1.1/MybatisEx-1.1-sources.jar[JENKINS] Archiving /root/.jenkins/workspace/ciHelper1.1/base-common/pom.xml to com.fastjrun.share/base-common/1.1/base-common-1.1.pom[JENKINS] Archiving /root/.jenkins/workspace/ciHelper1.1/base-common/target/base-common-1.1.jar to com.fastjrun.share/base-common/1.1/base-common-1.1.jar[JENKINS] Archiving /root/.jenkins/workspace/ciHelper1.1/base-common/target/base-common-1.1-sources.jar to com.fastjrun.share/base-common/1.1/base-common-1.1-sources.jarchannel stoppedFinished: SUCCESS
###jenkins中配置demo-parent,deploy到私服,截图如下
执行该任务,任务如下[INFO] Reactor Summary:[INFO] [INFO] demoSpring4-parent ................................. SUCCESS [ 2.326 s][INFO] demoSpring4-base ................................... SUCCESS [ 4.056 s][INFO] demoSpring4-util ................................... SUCCESS [ 4.394 s][INFO] demoSpring4-bundle ................................. SUCCESS [ 1.404 s][INFO] demoSpring4-persistence-impl ....................... SUCCESS [ 2.034 s][INFO] demoSpring4-service-impl ........................... SUCCESS [ 3.335 s][INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 20.335 s[INFO] Finished at: 2016-08-21T22:10:33+08:00[INFO] Final Memory: 41M/301M[INFO] ------------------------------------------------------------------------[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Service-Impl/pom.xml to com.fastjrun.share/demoSpring4-service-impl/1.1-SNAPSHOT/demoSpring4-service-impl-1.1-SNAPSHOT.pom[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Service-Impl/target/demoSpring4-service-impl-1.1-SNAPSHOT.jar to com.fastjrun.share/demoSpring4-service-impl/1.1-20160821.141032-1/demoSpring4-service-impl-1.1-20160821.141032-1.jar[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Service-Impl/target/demoSpring4-service-impl-1.1-SNAPSHOT-sources.jar to com.fastjrun.share/demoSpring4-service-impl/1.1-20160821.141032-1/demoSpring4-service-impl-1.1-20160821.141032-1-sources.jar[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/pom.xml to com.fastjrun.share/demoSpring4-parent/1.1-SNAPSHOT/demoSpring4-parent-1.1-SNAPSHOT.pom[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Base/pom.xml to com.fastjrun.share/demoSpring4-base/1.1-SNAPSHOT/demoSpring4-base-1.1-SNAPSHOT.pom[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Base/target/demoSpring4-base-1.1-SNAPSHOT.jar to com.fastjrun.share/demoSpring4-base/1.1-20160821.141020-1/demoSpring4-base-1.1-20160821.141020-1.jar[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Base/target/demoSpring4-base-1.1-SNAPSHOT-sources.jar to com.fastjrun.share/demoSpring4-base/1.1-20160821.141020-1/demoSpring4-base-1.1-20160821.141020-1-sources.jar[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Bundle/pom.xml to com.fastjrun.share/demoSpring4-bundle/1.1-SNAPSHOT/demoSpring4-bundle-1.1-SNAPSHOT.pom[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Bundle/target/demoSpring4-bundle-1.1-SNAPSHOT.jar to com.fastjrun.share/demoSpring4-bundle/1.1-20160821.141026-1/demoSpring4-bundle-1.1-20160821.141026-1.jar[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Bundle/target/demoSpring4-bundle-1.1-SNAPSHOT-sources.jar to com.fastjrun.share/demoSpring4-bundle/1.1-20160821.141026-1/demoSpring4-bundle-1.1-20160821.141026-1-sources.jar[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Util/pom.xml to com.fastjrun.share/demoSpring4-util/1.1-SNAPSHOT/demoSpring4-util-1.1-SNAPSHOT.pom[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Util/target/demoSpring4-util-1.1-SNAPSHOT.jar to com.fastjrun.share/demoSpring4-util/1.1-20160821.141024-1/demoSpring4-util-1.1-20160821.141024-1.jar[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Util/target/demoSpring4-util-1.1-SNAPSHOT-sources.jar to com.fastjrun.share/demoSpring4-util/1.1-20160821.141024-1/demoSpring4-util-1.1-20160821.141024-1-sources.jar[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Persistence-Impl/pom.xml to com.fastjrun.share/demoSpring4-persistence-impl/1.1-SNAPSHOT/demoSpring4-persistence-impl-1.1-SNAPSHOT.pom[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Persistence-Impl/target/demoSpring4-persistence-impl-1.1-SNAPSHOT.jar to com.fastjrun.share/demoSpring4-persistence-impl/1.1-20160821.141028-1/demoSpring4-persistence-impl-1.1-20160821.141028-1.jar[JENKINS] Archiving /root/.jenkins/workspace/demo-parent/Persistence-Impl/target/demoSpring4-persistence-impl-1.1-SNAPSHOT-sources.jar to com.fastjrun.share/demoSpring4-persistence-impl/1.1-20160821.141028-1/demoSpring4-persistence-impl-1.1-20160821.141028-1-sources.jarchannel stoppedFinished: SUCCESS
###jenkins中配置demo-Rest-config,将config.tar.gz直接scp到服务器D(192.168.9.4),截图如下
执行该任务,成功后可ssh到服务器D(192.168.9.3)在目录/app/demoSpring4/Rest下解压config.tar.gztar -zxvf config.tar.gz
###jenkins中配置demo-Rest,将demo-Rest.war直接scp到服务器D(192.168.9.4)的tomcat下,截图如下 执行该任务,成功后后服务器D(192.168.9.3)的tomcat会重新部署demo-Rest.war
###参考demo-Rest-config配置demo-Web-config ###参考demo-Web-config配置demo-Web
###jenkins中配置demo-Batch,将batch.tar.gz直接scp到服务器D(192.168.9.4),截图如下
执行该任务,成功后可ssh到服务器D(192.168.9.4)在目录/app/demoSpring4下解压batch.tar.gztar -zxvf batch.tar.gzcd batchnohup ./startup.sh
###示例环境
- demo-Web
- demo-Rest
###使用jenkins配置rest-test任务,可形成testng报告如下