windows jenkins 發佈 springboot項目腳本java
1.關閉現有程序 (按端口關閉) 【與按應用關閉 二選一】spring
@echo off set port=9000 for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do ( taskkill /pid %%m /f exit /b )
1.關閉現有程序 (按應用關閉) 【與按端口關閉 二選一】windows
@echo off for /f "tokens=1,2 delims= " %%a in ('jps -l') do ( if "%%b"=="app-1.0-SNAPSHOT.jar" (set pid=%%a)) if DEFINED pid taskkill /pid %pid% /f exit
2.mvn 編譯springboot
3.複製文件夾app
if not exist "E:\test" md "E:\test" copy .\target\app-1.0-SNAPSHOT.jar E:\test\app-1.0-SNAPSHOT.jar
4.啓動spa
@echo off cd E:\test\ E: start javaw -Dserver.port=9000 -jar app-1.0-SNAPSHOT.jar exit
注意:code
windows 切換目錄時 末尾要加 \server
如 cd E:\test\blog
同時也要再次入盤符 E:token