2.首先配置全局工具
Manage Jenkins==》Global Tool Configuration
配置JDK,GIT,Maven 注意,配置的是你自己本地的,不是我的路径
最后应用==》保存一波
3.插件管理
我们需要的插件GitLab,Maven Integration
- GitLab插件的作用是当gitlab有push时触发jenkins拉取代码和将构建状态发送回GitLab
- Maven Integration用来简化建造Maven工程.
4.配置邮箱
点击拉到最后
5.构建maven项目
点击新建Item
然后点击添加
cd D:\jenkins\Jenkins\workspace\Ktamr-java
mvn clean package -Dmaven.test.skip=true -Pdruid
@echo off
set port=9094
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do (
taskkill /pid %%m /f
exit /b
)
@echo off
set str_time_first_bit="%time:~0,1%"
if %str_time_first_bit%==" " (
set str_date_time=%date:~0,4%%date:~5,2%%date:~8,2%0%time:~1,1%%time:~3,2%%time:~6,2%
)else (
set str_date_time=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
)
if not exist "C:\work" md "C:\work"
if exist C:\work\ktamr-a-datacopycontrol.jar (
if not exist "C:\work\backup" md "C:\work\backup"
copy C:\work\ktamr-a-datacopycontrol.jar C:\work\backup\%str_date_time%.jar
del C:\work\ktamr-a-datacopycontrol.jar
)
cd D:\jenkins\Jenkins\workspace\Ktamr-java\ktamr-a-datacopycontrol\target
copy *.jar C:\work
cd c:\work
start javaw -jar ktamr-a-datacopycontrol.jar
exit 0
配置Build
pom.xml
clean install package
配置Post Steps
set BUILD_ID=dontKillMe
start javaw -jar C:\work\ktamr-a-datacopycontrol.jar --server.port=9094
构建设置
最后点击应用保存就OK
如果按照我的配置下来,启动的端口号是9094
如果发现博文中有错误,请各位老鸟多多指教