要求
- jenkin已经安装完成
参考我的上一篇博客:https://blog.csdn.net/kouryoushine/article/details/90765007
接下来要做的事情,就是把maven,git,jdk等需要的插件和组件,整合到当前的jenkin环境。
1、安装插件
Maven Integration plugin 安装此插件才能构建maven项目
Deploy to container Plugin 安装此插件,才能将打好的包部署到tomcat上
2、系统配置
环境变量
环境变量配置
系统设置中,可以配置java,git,mvn的环境变量。
3、全局工具配置(重要)
系统管理-》全局工具配置,打开后就是配置maven,git,tomcat,jdk等组件的地方。只有配置好了这些工具的信息,将来jenkins才能做到统一管理。
四 、
创建自动发布项目
配置项目地址,将来会从这个git copy项目代码
发布设置
**/XXX.war 这里路径**/ 避免路径不对找不到war包
说明
创建发布项目的配置页面,就是代码从打包到发布的整个流程需要做的事情
- 从你的git仓库拉取代码,默认master分支。 所以需要配置git地址和密码
- mvn执行打包,打包结果就放在jenkins服务器的workspace目录下。
- 将war包上传到服务器目录,这里目标是配置tomcat时指定的。http://localhost:8050 也就是发布时,tomcat需要运行状态
想要理解上面的过程,最好的方法就是自己发布一遍,当你发布成功后,看一下log,就理解了jenkins做了什么。
附发布成功的log
18:36:39 Waiting for Jenkins to finish collecting data
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/pom.xml to com.bian/bms/3.0/bms-3.0.pom
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/admin/pom.xml to com.bian/bian/3.0/bian-3.0.pom
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/admin/target/bian.war to com.bian/bian/3.0/bian-3.0.war
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/generator/pom.xml to com.bian/generator/3.0/generator-3.0.pom
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/generator/target/generator-3.0.jar to com.bian/generator/3.0/generator-3.0.jar
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/bms-service/pom.xml to com.bian/bms-service/3.0/bms-service-3.0.pom
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/bms-service/target/bms-service-3.0.jar to com.bian/bms-service/3.0/bms-service-3.0.jar
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/system/pom.xml to com.bian/system/3.0/system-3.0.pom
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/system/target/system-3.0.jar to com.bian/system/3.0/system-3.0.jar
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/quartz/pom.xml to com.bian/quartz/3.0/quartz-3.0.pom
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/quartz/target/quartz-3.0.jar to com.bian/quartz/3.0/quartz-3.0.jar
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/framework/pom.xml to com.bian/framework/3.0/framework-3.0.pom
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/framework/target/framework-3.0.jar to com.bian/framework/3.0/framework-3.0.jar
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/common/pom.xml to com.bian/common/3.0/common-3.0.pom
18:36:40 [JENKINS] Archiving /var/lib/jenkins/workspace/bms-test/common/target/common-3.0.jar to com.bian/common/3.0/common-3.0.jar
18:36:40 channel stopped
18:36:40 Deploying /var/lib/jenkins/workspace/bms-test/admin/target/bian.war to container Tomcat 8.x Remote with context bian
18:36:40 [/var/lib/jenkins/workspace/bms-test/admin/target/bian.war] is not deployed. Doing a fresh deployment.
18:36:40 Deploying [/var/lib/jenkins/workspace/bms-test/admin/target/bian.war]
18:37:02 Finished: SUCCESS`
``