windows server服务器CICD自动化脚本
fore-end
分发器:
#!/bin/env bash
host=$1
interval=$2
project=$3
echo $host
echo $interval
for b in `IFS=$',';echo $project`;do
echo $b
#echo "$IFS"|xxd -b
case $b in
"cjml-agent-factory")
echo cjml-agent-factory $host $interval
#start /wait "ping jd.com"
start /wait c:\\scripts\\cjml-agent-factory.bat $host $interval
;;
"cjml-embedded-factory")
echo cjml-embedded-factory $host $interval
start /wait c:\\scripts\\cjml-embedded-factory.bat $host $interval
;;
"cjml-embedded-h5")
echo cjml-embedded-h5 $host $interval
start /wait c:\\scripts\\cjml-embedded-h5.bat $host $interval
;;
"cjml-embedded-root")
echo cjml-embedded-root $host $interval
start /wait c:\\scripts\\cjml-embedded-root.bat $host $interval
;;
"CJML.Web.IM")
echo CJML.Web.IM $host $interval
start /wait c:\\scripts\\CJML.Web.IM.bat $host $interval
;;
"CJML.Web.CloudShopManage.H5")
echo CJML.Web.CloudShopManage.H5 $host $interval
start /wait c:\\scripts\\CJML.Web.CloudShopManage.H5.bat $host $interval
;;
"CJML.Web.CloudShopManage")
echo CJML.Web.CloudShopManage $host $interval
start /wait c:\\scripts\\CJML.Web.CloudShopManage.bat $host $interval
;;
"CJML.Web.CloudShop.H5")
echo CJML.Web.CloudShop.H5 $host $interval
start /wait c:\\scripts\\CJML.Web.CloudShop.H5.bat $host $interval
;;
"CJML.CloudShop.ManageUI")
echo CJML.CloudShop.ManageUI $host $interval
start /wait c:\\scripts\\CJML.CloudShop.ManageUI.bat $host $interval
;;
"CJML.APP.IntelliP.H5")
echo CJML.APP.IntelliP.H5 $host $interval
start /wait c:\\scripts\\CJML.APP.IntelliP.H5.bat $host $interval
;;
"CJML.APP.IntelliP")
echo CJML.APP.IntelliP $host $interval
start /wait c:\\scripts\\CJML.APP.IntelliP.bat $host $interval
;;
"CJML.APP.Activities.H5")
echo CJML.APP.Activities.H5 $host $interval
start /wait c:\\scripts\\CJML.APP.Activities.H5.bat $host $interval
;;
"CJML.Web.WMS")
echo CJML.Web.WMS $host $interval
start /wait c:\\scripts\\CJML.Web.WMS.bat $host $interval
;;
"CJML.IM.H5")
echo CJML.IM.H5 $host $interval
start /wait c:\\scripts\\CJML.IM.H5.bat $host $interval
;;
"CJML.IM.UI")
echo CJML.IM.UI $host $interval
start /wait c:\\scripts\\CJML.IM.UI.bat $host $interval
;;
*)
echo no such project!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;;
esac
done
@echo off
echo.
echo ***************************************************************************************
echo current project = cjml-embedded-factory
set host=%1
set ecs=%host:~0,22%
set server=%host:~23,99%
echo The Current Host: %host% !!
echo ecs=%ecs%
echo server=%server%
echo ***************************************************************************************
echo.
if %server% == 172.16.20.106 ( goto unicore ) else ( goto release )
:unicore
echo.
echo ***************************************************************************************
echo Get Current Time!!
echo ***************************************************************************************
chcp 936
set NOW_TIME_HH=%time:~0,2%
if "%NOW_TIME_HH%" lss "10" (set NOW_TIME_HH=0%time:~1,1%) else (set NOW_TIME_HH=%time:~0,2%)
set NOW_TIME=%date:~0,4%-%date:~5,2%-%date:~8,2%_%NOW_TIME_HH%-%time:~3,2%-%time:~6,2%
echo Current Time:%NOW_TIME%
echo.
echo ***************************************************************************************
echo backup!!
echo ***************************************************************************************
chcp 65001
"C:\Program Files\OpenSSH\ssh" administrator@%server% "C:\Progra~1\7-Zip\7z.exe a -r -snl D:\backup\cjml-embedded-factory-%NOW_TIME%.zip D:\website\51cjml.com\cjml-embedded-factory\*"
if not %errorlevel% == 0 goto releasefailed
echo.
echo ***************************************************************************************
echo Release of static resources!!
echo ***************************************************************************************
chcp 65001
"C:\Program Files\OpenSSH\scp" -r "\\192.168.100.163\share\CJML\cjml-embedded-factory\线上包\webresources\factoryUI\*" "\\172.16.30.2\files\51cjml.com\c1\webresources\factoryUI"
if not %errorlevel% == 0 goto releasefailed
:release
echo.
echo ***************************************************************************************
echo DEPLOY CORE MODULE...
echo ***************************************************************************************
echo.
echo.
echo ***************************************************************************************
echo Adjuest Weight of %server% to zero!!
echo ***************************************************************************************
chcp 65001
%systemroot%\adjust "lb-uf6sljbd851v9pgrng6nk" "%ecs%" "0"
%systemroot%\adjust "lb-uf611bih0o3phcwzivxfe" "%ecs%" "0"
if not %errorlevel% == 0 goto releasefailed
echo.
echo ***************************************************************************************
echo Wait %2 seconds
echo ***************************************************************************************
ping -n %2 -w 1000 localhost >nul
echo.
echo ***************************************************************************************
echo Publish %server%!!
echo ***************************************************************************************
chcp 65001
"C:\Program Files\OpenSSH\scp" -r "\\192.168.100.163\share\CJML\cjml-embedded-factory\线上包\app\*" administrator@%server%:D:\website\51cjml.com\cjml-embedded-factory
if not %errorlevel% == 0 goto releasefailed
echo.
echo ***************************************************************************************
echo Wait 60 seconds
echo ***************************************************************************************
ping -n %2 -w 1000 localhost >nul
echo.
echo ***************************************************************************************
echo Adjuest Weight of %server% to One Hundred!!
echo ***************************************************************************************
chcp 65001
%systemroot%\adjust "lb-uf6sljbd851v9pgrng6nk" "%ecs%" "100"
%systemroot%\adjust "lb-uf611bih0o3phcwzivxfe" "%ecs%" "100"
if not %errorlevel% == 0 goto releasefailed
goto releasesuccess
:releasesuccess
echo.
echo.
echo ***************************************************************************************
echo RELEASE SUCCESS!!
echo ***************************************************************************************
goto end
:releasefailed
echo.
echo.
echo ***************************************************************************************
echo RELEASE FAILED!!
echo ***************************************************************************************
goto end
:end
echo.
echo.
echo ***************************************************************************************
echo RELEASE FINISHED!!
echo ***************************************************************************************