Jenkins自动构建TFS项目并自动化测试接口后发送邮件

Jenkins的配置网上有很多,这里就不赘述了,只记录一些关键命令。

Jenkins配置截图
Build a Visual Studio project or solution using MSBuild:

/t:Rebuild
/p:Configuration=Release
/p:VisualStudioVersion=16.0
/p:WebProjectOutputDir=E:\JenkinsWebYKT
/p:OutputPath=E:\JenkinsWebYKTRelease
/p:DeployOnBuild=True

Execute Windows batch command(接口自动化测试):

copy /y "E:\WebYKTRelease\Web.config.bak" "E:\JenkinsWebYKT\Web.config"
cd \
cd c:\Users\Administrator\AppData\Roaming\npm
newman run "E:\WebYKTRelease\webykt.postman_collection.json" --bail --reporters html --reporter-html-export "E:\WebYKTRelease\webykt.postman_report.html"

Execute Windows batch command(整理打包):

# 整理打包
forfiles /p "E:\WebYKTRelease" /s /m *.zip /d -7 /c "cmd /c del @path"
forfiles /p "E:\WebYKTRelease" /s /m *.txt /d -7 /c "cmd /c del @path"
set "ymd=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%"
if "%TIME:~0,1%" == " " (set "hms=0%TIME:~1,1%%TIME:~3,2%%TIME:~6,2%") else (set "hms=%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%")
md "E:\WebYKTRelease\%ymd%"
"C:\Program Files\WinRAR\WinRAR.exe" a -afzip -ep1 "E:\WebYKTRelease\%ymd%\webykt_%ymd%_%hms%_bin.正在打包" "E:\JenkinsWebYKT\bin"
ren "E:\WebYKTRelease\%ymd%\webykt_%ymd%_%hms%_bin.正在打包" "webykt_%ymd%_%hms%_bin.zip"
"C:\Program Files\WinRAR\WinRAR.exe" a -afzip -ep1 "E:\WebYKTRelease\%ymd%\webykt_%ymd%_%hms%_all.正在打包" "E:\JenkinsWebYKT"
ren "E:\WebYKTRelease\%ymd%\webykt_%ymd%_%hms%_all.正在打包" "webykt_%ymd%_%hms%_all.zip"
del /a /f /s "E:\WebYKTRelease\webykt_bin_latest_打包完成.txt" 
copy /y "E:\WebYKTRelease\%ymd%\webykt_%ymd%_%hms%_bin.zip" "E:\WebYKTRelease\webykt_bin_latest.zip"
echo 最新webykt_%ymd%_%hms%_bin打包完成>"E:\WebYKTRelease\webykt_bin_latest_打包完成.txt"
del /a /f /s "E:\WebYKTRelease\webykt_all_latest_打包完成.txt" 
copy /y "E:\WebYKTRelease\%ymd%\webykt_%ymd%_%hms%_all.zip" "E:\WebYKTRelease\webykt_all_latest.zip"
echo 最新webykt_%ymd%_%hms%_all打包完成>"E:\WebYKTRelease\webykt_all_latest_打包完成.txt"

猜你喜欢

转载自blog.csdn.net/danding_ge/article/details/109287174