项目需要每天自动编译代码,运行test case,然后发邮件给项目组里的人。这个工作本来可以用hudson来做的,但因为自己要改一些文件,感觉用dos命令比较方便。hudson下次再学吧。
用dos命令做的步骤是:
1.建立windows计划任务,让它定点运行bat文件
2.在P4上建立daily build需要的client
3.bat文件中做的工作包括:
> dos命令将P4上的代码下载到本地
> 将需要更新的文档复制到相应的文件夹
> 调用mvn clean install命令编译文件,运行相应的test case
> 将编译结果发给组内成员
下面是dos代码
d:
p4 set P4PORT=10.40.30.19:1666
p4 set P4USER=ffan
p4 set P4PASSWD=Frank7#
p4 set P4CLIENT=DailyBuilder130
echo '------------p4 sync main----------------'
p4 sync //depot/engineering/projects/z7/dev/delibird_udm_phase1/...
set root=d:\depot
set fileDir=d:\delibird
set filename=buildResult%date:~0,2%%date:~3,2%%date:~6,4%.log
set to=ffan@seven.com;tzhang@seven.com;tyan@seven.com;nsi@seven.com;dlan@seven.com;zhao@seven.com
echo 'copy daily builder config file'
copy %fileDir%\dailybuilderConfig\z7.properties %root%\engineering\projects\z7\dev\delibird_udm_phase1\java\z7-data\src\test\resources\
copy %fileDir%\dailybuilderConfig\pom.xml %root%\engineering\projects\z7\dev\delibird_udm_phase1\java\z7-data\
if exist %root%\engineering\projects\z7\dev\delibird_udm_phase1\output ( rmdir /s /q %root%\engineering\projects\z7\dev\delibird_udm_phase1\output )
echo '------------p4 sync main finish---------'
cd %root%/engineering/projects/z7/dev/delibird_udm_phase1/java
set MAVEN_OPTS=-Xms256m -Xmx512m
echo '------------mvn clean install-------------------'
mvn clean install > %fileDir%\%filename% &cd %fileDir% & java -cp SendEmail.jar;lib\mail-1.4.4.jar com.seven.sendemail.SendEmail -f %filename% -to %to% -s DailyBuildReport & move .\%filename% \\hzs-dc1\public\frank_fan & start dudutest.bat
接下来需要下载SVN上的代码然后运行test case
d:
TortoiseProc.exe /command:update /path:"D:\udm" /closeonend:1
set root=d:\depot
set fileDir=d:\delibird
set filename=dudutest%date:~0,2%%date:~3,2%%date:~6,4%.log
set to=ffan@seven.com;tzhang@seven.com;tyan@seven.com;nsi@seven.com;dlan@seven.com;zhao@seven.com
echo 'copy daily builder config file'
copy %fileDir%\dudutestConfig\z7.properties %root%\engineering\projects\z7\dev\delibird_udm_phase1\output\dev\binaries\java\z7-relay\z7-relay-SNAPSHOT\config
copy %fileDir%\dudutestConfig\z7.properties %root%\engineering\projects\z7\dev\delibird_udm_phase1\output\dev\binaries\java\z7-ce-connector\z7-ce-connector-SNAPSHOT\config
cd %fileDir%
start relay.bat
start ce.bat
sleep 50
set MAVEN_OPTS=-Xms256m -Xmx512m
echo '------------mvn clean install-------------------'
cd D:\udm\
mvn clean install > %fileDir%\%filename% &cd %fileDir% & java -cp SendEmail.jar;lib\mail-1.4.4.jar com.seven.sendemail.SendEmail -f %filename% -to %to% -s DuduTestReport & move .\%filename% \\hzs-dc1\public\frank_fan & taskkill /f /T /fi "windowtitle eq ceBat" & taskkill /f /T /fi "windowtitle eq relayBat"