配合Jenkins自动化构建,bat脚本(二)
批量通过模板,拷贝文件,然后替换模板文件中的标记位为预制的内容。
1 Set servicePath=Ehong.MedicareReview.Web\地区配置\ 2 Set webPath=Ehong.MedicareReview.Web\ 3 Set current=%~dp0 4 5 rem 1.创建审核的配置文件 6 Set targetPath=%current%%servicePath%%targetArea% 7 rd /s /q "%targetPath%" 8 mkdir "%targetPath%" 9 10 echo f | xcopy /y "replace.bat" "%current%%webPath%\replace.bat" 11 12 rem 2.进入目录 13 cd "%webPath%" 14 15 rem 3.拷贝文件并重命名 16 echo f | xcopy /y "settings_debug_%fadebackmodel%.xml" "temp0.xml" 17 start replace.bat 18 19 :11 20 if not exist succeed.txt goto :11 21 22 echo f | xcopy "temp1.xml" "%targetPath%/settings.xml" 23 echo f | xcopy "temp1.xml" "%targetPath%/settings_debug.xml" 24 rem 4.svn附加文件 25 svn add "%targetPath%" --username wangzhen --password wz123 26 27 if exist temp0.xml del temp0.xml 2>nul 28 if exist temp1.xml del temp1.xml 2>nul 29 if exist succeed.txt del succeed.txt 2>nul 30 if exist replace.bat del replace.bat 2>nul 31 32 exit
以上 拷贝需要的文件
1 chcp 65001 2 @echo off & if exist temp1.config del temp1.config 2>nul 3 for /f "tokens=*" %%i in (temp0.config) do ( 4 setlocal disabledelayedexpansion 5 endlocal 6 if "%%i"=="" (echo.) else ( 7 set "line=%%i" 8 setlocal enabledelayedexpansion 9 call :chg 10 endlocal 11 ) 12 ) 13 echo succeed>>succeed.txt 14 exit 15 16 :chg 17 set "line=!line:DevelopArea=%targetArea%!" 18 echo !line!>>temp1.config 19 goto :eof
以上替换文件中的内容