windows Jenkins gitee 多个springboot 持续集成构建

1.新建Item

  • 主页选择 -> 新建Item

  • 输入任务名称,选择 -> 构建一个maven项目

2.添加项目描述

3.源码管理(git)

4.构建触发器

5.构建环境

根据自己需求选择

6.Pre Steps

添加Windows batch command命令,构建前杀掉对应的进程,例如demo-1.0.2.jar所对应的进程

 
  1. @echo off

  2. for /f "tokens=1,2 delims=" %%a in ('jps') do (if "%%b"=="demo-1.0.1.jar" (set pid=%%a))

  3. if DEFINED pid taskkill /pid %pid% /f

7.Build(构建)

8.Pre Steps

添加Windows batch command命令,后台运行编译好的jar,-Dfile.encoding指定编码格式

 
  1. @echo off

  2. xcopy D:\jenkins\workspace\demo\target\demo-1.0.1.jar D:\demo\ /Y

  3. start javaw -jar -Dfile.encoding=utf-8 D:\demo\demo-1.0.1.jar &

  4. echo - - - - - - - - - - - - - - - - - demo.jar 启动成功! - - - - - - - - - - - - - - - - -

  5. exit

9.构建后操作

根据自己需求选择,例如发送邮件等

10.添加环境变量,否则构建完成后自动杀掉jar

  • 系统管理(Manage Jenkins)–> 管理节点(Manage Nodes and Clouds)
  • 找到发包节点(master),点击设置
  • 点击Environment variables,增加环境变量,保存后执行构建

批量脚本 Pre:

@echo off
for /f "tokens=1,2 delims= " %%a in ('jps') do (
    if "%%b"=="ybtcloud-coplt-service-1.0-SNAPSHOT.jar" (
        set pid=%%a
        echo %%a
    )
)
if DEFINED pid (
    taskkill /pid %pid% /f
)
echo - - - - - - - - - - - - - - - - - ybtcloud-coplt-service-1.0-SNAPSHOT.jar 停止成功! - - - - - - - - - - - - - - - - -


for /f "tokens=1,2 delims= " %%a in ('jps') do (
    if "%%b"=="ybtcloud-ecologev-service-1.0-SNAPSHOT.jar" (
        set pid=%%a
        echo %%a
    )
)
if DEFINED pid (
    taskkill /pid %pid% /f
)
echo - - - - - - - - - - - - - - - - - ybtcloud-ecologev-service-1.0-SNAPSHOT.jar 停止成功! - - - - - - - - - - - - - - - - -

for /f "tokens=1,2 delims= " %%a in ('jps') do (
    if "%%b"=="ybtcloud-file-service-1.0-SNAPSHOT.jar" (
        set pid=%%a
        echo %%a
    )
)
if DEFINED pid (
    taskkill /pid %pid% /f
)
echo - - - - - - - - - - - - - - - - - ybtcloud-file-service-1.0-SNAPSHOT.jar 停止成功! - - - - - - - - - - - - - - - - -


for /f "tokens=1,2 delims= " %%a in ('jps') do (
    if "%%b"=="ybtcloud-form-service-1.0-SNAPSHOT.jar" (
        set pid=%%a
        echo %%a
    )
)
if DEFINED pid (
    taskkill /pid %pid% /f
)
echo - - - - - - - - - - - - - - - - - ybtcloud-form-service-1.0-SNAPSHOT.jar 停止成功! - - - - - - - - - - - - - - - - -


for /f "tokens=1,2 delims= " %%a in ('jps') do (
    if "%%b"=="imq-admin.jar" (
        set pid=%%a
        echo %%a
    )
)
if DEFINED pid (
    taskkill /pid %pid% /f
)
echo - - - - - - - - - - - - - - - - - imq-admin.jar 停止成功! - - - - - - - - - - - - - - - - -


for /f "tokens=1,2 delims= " %%a in ('jps') do (
    if "%%b"=="ybtcloud-ncqc-service-1.0-SNAPSHOT.jar" (
        set pid=%%a
        echo %%a
    )
)
if DEFINED pid (
    taskkill /pid %pid% /f
)
echo - - - - - - - - - - - - - - - - - ybtcloud-ncqc-service-1.0-SNAPSHOT.jar 停止成功! - - - - - - - - - - - - - - - - -


for /f "tokens=1,2 delims= " %%a in ('jps') do (
    if "%%b"=="ybtcloud-plt-service-1.0-SNAPSHOT.jar" (
        set pid=%%a
        echo %%a
    )
)
if DEFINED pid (
    taskkill /pid %pid% /f
)
echo - - - - - - - - - - - - - - - - - ybtcloud-plt-service-1.0-SNAPSHOT.jar 停止成功! - - - - - - - - - - - - - - - - -


for /f "tokens=1,2 delims= " %%a in ('jps') do (
    if "%%b"=="ybtcloud-pve-service-1.0-SNAPSHOT.jar" (
        set pid=%%a
        echo %%a
    )
)
if DEFINED pid (
    taskkill /pid %pid% /f
)
echo - - - - - - - - - - - - - - - - - ybtcloud-pve-service-1.0-SNAPSHOT.jar 停止成功! - - - - - - - - - - - - - - - - -

for /f "tokens=1,2 delims= " %%a in ('jps') do (
    if "%%b"=="ybtcloud-qcp-service-1.0-SNAPSHOT.jar" (
        set pid=%%a
        echo %%a
    )
)
if DEFINED pid (
    taskkill /pid %pid% /f
)
echo - - - - - - - - - - - - - - - - - ybtcloud-qcp-service-1.0-SNAPSHOT.jar 停止成功! - - - - - - - - - - - - - - - - -

for /f "tokens=1,2 delims= " %%a in ('jps') do (
    if "%%b"=="ybtcloud-qcs-service-1.0-SNAPSHOT.jar" (
        set pid=%%a
        echo %%a
    )
)
if DEFINED pid (
    taskkill /pid %pid% /f
)
echo - - - - - - - - - - - - - - - - - ybtcloud-qcs-service-1.0-SNAPSHOT.jar 停止成功! - - - - - - - - - - - - - - - - -


 
for /f "tokens=1,2 delims= " %%a in ('jps') do (
    if "%%b"=="ybtcloud-qcs-service-1.0-SNAPSHOT.jar" (
        set pid=%%a
        echo %%a
    )
)
if DEFINED pid (
    taskkill /pid %pid% /f
)
echo - - - - - - - - - - - - - - - - - ybtcloud-qcs-service-1.0-SNAPSHOT.jar 停止成功! - - - - - - - - - - - - - - - - -


 
for /f "tokens=1,2 delims= " %%a in ('jps') do (
    if "%%b"=="ybtcloud-teo-service-1.0-SNAPSHOT.jar" (
        set pid=%%a
        echo %%a
    )
)
if DEFINED pid (
    taskkill /pid %pid% /f
)
echo - - - - - - - - - - - - - - - - - ybtcloud-teo-service-1.0-SNAPSHOT.jar 停止成功! - - - - - - - - - - - - - - - - -

批量脚本 Post:
 

set BUILD_ID=dontKillMe
set JENKINS_NODE_COOKIE=dontKillMe
@echo off
echo  ybtcloud-coplt-service-1.0-SNAPSHOT.jar
xcopy D:\ProgramFiles\Jenkins\workspace\Jenkins\.jenkins\workspace\ybtcloud\ybtcloud-coplt\ybtcloud-coplt-service\target\ybtcloud-coplt-service-1.0-SNAPSHOT.jar  D:\ybtcloud\ybtcloud-coplt\  /Y
cd D:\ybtcloud\ybtcloud-coplt\
start C:\ProgramFiles\Java\jdk1.8.0_181\bin\javaw -Xms256m -Xmx512m      -Dspring.profiles.active=prod -jar ybtcloud-coplt-service-1.0-SNAPSHOT.jar & 
echo - - - - - - - - - - - - - - - - - ybtcloud-coplt-service-1.0-SNAPSHOT.jar 启动成功! - - - - - - - - - - - - - - - - -

echo ybtcloud-ecologev-service-1.0-SNAPSHOT.jar
xcopy D:\ProgramFiles\Jenkins\workspace\Jenkins\.jenkins\workspace\ybtcloud\ybtcloud-ecologev\ybtcloud-ecologev-service\target\ybtcloud-ecologev-service-1.0-SNAPSHOT.jar  D:\ybtcloud\ybtcloud-ecologev\  /Y
cd D:\ybtcloud\ybtcloud-ecologev\
start C:\ProgramFiles\Java\jdk1.8.0_181\bin\javaw -Xms256m -Xmx512m      -Dspring.profiles.active=prod -jar ybtcloud-ecologev-service-1.0-SNAPSHOT.jar & 
echo - - - - - - - - - - - - - - - - - ybtcloud-coplt-service-1.0-SNAPSHOT.jar 启动成功! - - - - - - - - - - - - - - - - -


echo ybtcloud-file-service-1.0-SNAPSHOT.jar
xcopy D:\ProgramFiles\Jenkins\workspace\Jenkins\.jenkins\workspace\ybtcloud\ybtcloud-file-center\ybtcloud-file-service\target\ybtcloud-file-service-1.0-SNAPSHOT.jar  D:\ybtcloud\ybtcloud-file\  /Y
cd D:\ybtcloud\ybtcloud-file\
start C:\ProgramFiles\Java\jdk1.8.0_181\bin\javaw -Xms256m -Xmx512m    -Dspring.profiles.active=prod -jar ybtcloud-file-service-1.0-SNAPSHOT.jar & 
echo - - - - - - - - - - - - - - - - - ybtcloud-file-service-1.0-SNAPSHOT.jar 启动成功! - - - - - - - - - - - - - - - - -


echo ybtcloud-form-service-1.0-SNAPSHOT.jar
xcopy D:\ProgramFiles\Jenkins\workspace\Jenkins\.jenkins\workspace\ybtcloud\ybtcloud-form\ybtcloud-form-service\target\ybtcloud-form-service-1.0-SNAPSHOT.jar  D:\ybtcloud\ybtcloud-form\  /Y

cd  D:\ybtcloud\ybtcloud-form\
start C:\ProgramFiles\Java\jdk1.8.0_181\bin\javaw -Xms256m -Xmx512m    -Dspring.profiles.active=prod -jar ybtcloud-form-service-1.0-SNAPSHOT.jar & 
echo - - - - - - - - - - - - - - - - - ybtcloud-form-service-1.0-SNAPSHOT.jar 启动成功! - - - - - - - - - - - - - - - - -

echo imq-admin.jar

xcopy D:\ProgramFiles\Jenkins\workspace\Jenkins\.jenkins\workspace\ybtcloud\ybtcloud-imq\imq-admin\target\imq-admin.jar  D:\ybtcloud\ybtcloud-imq\  /Y
cd D:\ybtcloud\ybtcloud-imq\ 
start C:\ProgramFiles\Java\jdk1.8.0_181\bin\javaw -Xms256m -Xmx512m    -Dspring.profiles.active=prod -jar imq-admin.jar & 
echo - - - - - - - - - - - - - - - - - imq-admin.jar 启动成功! - - - - - - - - - - - - - - - - -

echo ybtcloud-ncqc-service-1.0-SNAPSHOT.jar

xcopy D:\ProgramFiles\Jenkins\workspace\Jenkins\.jenkins\workspace\ybtcloud\ybtcloud-ncqc\ybtcloud-ncqc-service\target\ybtcloud-ncqc-service-1.0-SNAPSHOT.jar  D:\ybtcloud\ybtcloud-ncqc\  /Y
cd D:\ybtcloud\ybtcloud-ncqc\
start C:\ProgramFiles\Java\jdk1.8.0_181\bin\javaw -Xms256m -Xmx512m    -Dspring.profiles.active=prod -jar ybtcloud-ncqc-service-1.0-SNAPSHOT.jar & 
echo - - - - - - - - - - - - - - - - - ybtcloud-ncqc-service-1.0-SNAPSHOT.jar 启动成功! - - - - - - - - - - - - - - - - -

echo ybtcloud-plt-service-1.0-SNAPSHOT.jar

xcopy D:\ProgramFiles\Jenkins\workspace\Jenkins\.jenkins\workspace\ybtcloud\ybtcloud-plt\ybtcloud-plt-service\target\ybtcloud-plt-service-1.0-SNAPSHOT.jar  D:\ybtcloud\ybtcloud-plt\  /Y
cd D:\ybtcloud\ybtcloud-plt\
start C:\ProgramFiles\Java\jdk1.8.0_181\bin\javaw -Xms256m -Xmx512m    -Dspring.profiles.active=prod -jar ybtcloud-plt-service-1.0-SNAPSHOT.jar & 
echo - - - - - - - - - - - - - - - - - ybtcloud-plt-service-1.0-SNAPSHOT.jar 启动成功! - - - - - - - - - - - - - - - - -

echo ybtcloud-pve-service-1.0-SNAPSHOT.jar
xcopy D:\ProgramFiles\Jenkins\workspace\Jenkins\.jenkins\workspace\ybtcloud\ybtcloud-pve\ybtcloud-pve-service\target\ybtcloud-pve-service-1.0-SNAPSHOT.jar  D:\ybtcloud\ybtcloud-pve\  /Y
cd D:\ybtcloud\ybtcloud-pve\
start C:\ProgramFiles\Java\jdk1.8.0_181\bin\javaw -Xms256m -Xmx512m    -Dspring.profiles.active=prod -jar ybtcloud-pve-service-1.0-SNAPSHOT.jar & 
echo - - - - - - - - - - - - - - - - - ybtcloud-pve-service-1.0-SNAPSHOT.jar 启动成功! - - - - - - - - - - - - - - - - -

echo ybtcloud-qcp-service-1.0-SNAPSHOT.jar

xcopy D:\ProgramFiles\Jenkins\workspace\Jenkins\.jenkins\workspace\ybtcloud\ybtcloud-qcpmanage\ybtcloud-qcp-service\target\ybtcloud-qcp-service-1.0-SNAPSHOT.jar  D:\ybtcloud\ybtcloud-qcp\  /Y
cd  D:\ybtcloud\ybtcloud-qcp\ 
start C:\ProgramFiles\Java\jdk1.8.0_181\bin\javaw -Xms256m -Xmx512m   -Dspring.profiles.active=prod -jar ybtcloud-qcp-service-1.0-SNAPSHOT.jar & 
echo - - - - - - - - - - - - - - - - - ybtcloud-qcp-service-1.0-SNAPSHOT.jar 启动成功! - - - - - - - - - - - - - - - - -

echo ybtcloud-qcs-service-1.0-SNAPSHOT.jar

xcopy D:\ProgramFiles\Jenkins\workspace\Jenkins\.jenkins\workspace\ybtcloud\ybtcloud-qcs-parent\ybtcloud-qcs-service\target\ybtcloud-qcs-service-1.0-SNAPSHOT.jar  D:\ybtcloud\ybtcloud-qcs\  /Y
cd   D:\ybtcloud\ybtcloud-qcs\ 
start C:\ProgramFiles\Java\jdk1.8.0_181\bin\javaw -Xms256m -Xmx512m    -Dspring.profiles.active=prod -jar ybtcloud-qcs-service-1.0-SNAPSHOT.jar & 
echo - - - - - - - - - - - - - - - - - ybtcloud-qcs-service-1.0-SNAPSHOT.jar 启动成功! - - - - - - - - - - - - - - - - -

echo ybtcloud-teo-service-1.0-SNAPSHOT.jar

xcopy D:\ProgramFiles\Jenkins\workspace\Jenkins\.jenkins\workspace\ybtcloud\ybtcloud-teo\ybtcloud-teo-service\target\ybtcloud-teo-service-1.0-SNAPSHOT.jar  D:\ybtcloud\ybtcloud-teo\  /Y
cd   D:\ybtcloud\ybtcloud-teo\ 
start C:\ProgramFiles\Java\jdk1.8.0_181\bin\javaw -Xms256m -Xmx512m    -Dspring.profiles.active=prod   -jar ybtcloud-teo-service-1.0-SNAPSHOT.jar & 
echo - - - - - - - - - - - - - - - - - ybtcloud-teo-service-1.0-SNAPSHOT.jar 启动成功! - - - - - - - - - - - - - - - - -




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

houzhanwublog

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值