windows环境Jenkins配置与使用(springboot+war包+vue)
一、后台发布
1、General配置
2、源码管理
3、构建触发器
4、构建环境
5、构建
clean install -Dmaven.test.skip=true -Ptest
6、Post Steps
call "C:\Users\Administrator\Desktop\stopTomcat.bat"
call "C:\Users\Administrator\Desktop\run-mes.bat"
stopTomcat.bat @echo off set CATALINA_HOME=C:\java\apache-tomcat-8.5.55 set CATALINA_BASE=C:\java\apache-tomcat-8.5.55 set CATALINA_TMPDIR=C:\java\apache-tomcat-8.5.55 cd "C:\java\apache-tomcat-8.5.55\bin\" title Tomcat重啟脚本 call shutdown.bat ping -n 6 127.1 >nul exit
run-mes.bat @echo off set BUILD_ID=dontkillme set CATALINA_HOME=C:\java\apache-tomcat-8.5.55 set CATALINA_BASE=C:\java\apache-tomcat-8.5.55 set CATALINA_TMPDIR=C:\java\apache-tomcat-8.5.55 cd "C:\java\apache-tomcat-8.5.55\webapps\" if exist "C:\java\apache-tomcat-8.5.55\webapps\mes-api.war" del "C:\java\apache-tomcat-8.5.55\webapps\mes-api.war" cd "C:\Users\Administrator\.jenkins\jobs\lh-mes\workspace\mes-applications-parent\mes-applications-api\target\" copy "C:\Users\Administrator\.jenkins\jobs\lh-mes\workspace\mes-applications-parent\mes-applications-api\target\mes-api.war" "C:\java\apache-tomcat-8.5.55\webapps\mes-api.war" if exist "C:\java\apache-tomcat-8.5.55\webapps\mes-api" rd /s /q "C:\java\apache-tomcat-8.5.55\webapps\mes-api" cd "C:\java\apache-tomcat-8.5.55\bin\" call startup.bat ping -n 45 127.1 >nul echo good bye
二、前台发布
1、开始配置同上,构建环境
2、构建
npm i
npm run build
call "C:\Users\Administrator\Desktop\stopTomcat.bat"
call "C:\Users\Administrator\Desktop\run-mes-web.bat"
stopTomcat.bat @echo off set CATALINA_HOME=C:\java\apache-tomcat-8.5.55 set CATALINA_BASE=C:\java\apache-tomcat-8.5.55 set CATALINA_TMPDIR=C:\java\apache-tomcat-8.5.55 cd "C:\java\apache-tomcat-8.5.55\bin\" title Tomcat重啟脚本 call shutdown.bat ping -n 6 127.1 >nul exit
run-mes-web.bat @echo off set BUILD_ID=dontkillme set CATALINA_HOME=C:\java\apache-tomcat-8.5.55 set CATALINA_BASE=C:\java\apache-tomcat-8.5.55 set CATALINA_TMPDIR=C:\java\apache-tomcat-8.5.55 if exist "C:\java\apache-tomcat-8.5.55\webapps\mes\" rd /s /q "C:\java\apache-tomcat-8.5.55\webapps\mes\" md "C:\java\apache-tomcat-8.5.55\webapps\mes" cd "C:\Users\Administrator\.jenkins\jobs\lh-mes-web\workspace\" xcopy "C:\Users\Administrator\.jenkins\jobs\lh-mes-web\workspace\dist\*.*" "C:\java\apache-tomcat-8.5.55\webapps\mes\" /s /e /c /y /h /r cd "C:\java\apache-tomcat-8.5.55\bin\" call startup.bat ping -n 45 127.1 >nul echo good bye
三、问题记录
1、进入jenkins启动项目构建后,出现tomacat闪退现象,现象为jenkins会杀死Tomcat进程
解决方案:bat命令中设置BUILD_ID环境变量,修改BUILD_ID序号,例如:set BUILD_ID=dontkillme
做人如果没有梦想,那根咸鱼有什么区别!!!