CruiseControl:簡稱CC,持續(xù)集成工具,主要提供了基于版本管理工具(如CVS)感知變化或每天定時(shí)的持續(xù)集成,并提供持續(xù)集成報(bào)告、Email、Jabber等等方式通知相關(guān)負(fù)責(zé)人,其要求是需要進(jìn)行日構(gòu)建的項(xiàng)目已編寫好全自動(dòng)的項(xiàng)目編譯腳本(可基于Maven或Ant)。
在這里以一個(gè)項(xiàng)目來簡要的說說cc的使用,通常項(xiàng)目對(duì)于日構(gòu)建的類型的需求分為兩種:
1、每天的定時(shí)自動(dòng)集成。
2、感知版本管理工具中的變化而進(jìn)行自動(dòng)集成。
項(xiàng)目對(duì)于日構(gòu)建的目標(biāo)通常為:
1、感知版本管理工具的變化,如發(fā)現(xiàn)有變化,則進(jìn)行集成。
2、調(diào)用項(xiàng)目編譯腳本進(jìn)行項(xiàng)目集成。
3、合并項(xiàng)目編譯腳本產(chǎn)生的單元測(cè)試、功能測(cè)試的日志。
4、將集成報(bào)告發(fā)布至網(wǎng)站中。
5、將集成的結(jié)果以郵件、jabber等等方式通知相應(yīng)的負(fù)責(zé)人。
基于上面的要求,項(xiàng)目編譯腳本采用Maven,版本管理工具采用CVS,持續(xù)集成工具采用CC,假設(shè)已編寫好了基于Maven的項(xiàng)目編譯腳本,CruiseControl的腳本如下編寫:
<?xml version="1.0" encoding="UTF-8"?>
<cruisecontrol>
<project name="demo" buildafterfailed="true">
<!-- 每次檢測(cè)是否有變化時(shí)先運(yùn)行此處 -->
<bootstrappers>
<currentbuildstatusbootstrapper file="logs/demo/buildstatus.txt"/>
</bootstrappers>
<!-- 檢測(cè)是否有變化,如有變化則開始集成 -->
<modificationset quietperiod="10">
<!-- 基于cvs的檢測(cè) -->
<cvs localworkingcopy="demo"/>
</modificationset>
<!-- 持續(xù)集成-->
<schedule interval="18">
<!-- 項(xiàng)目的編譯腳本 -->
<maven mavenscript="D:/tools/maven/bin/maven.bat"
projectfile="demo/project.xml"
goal="demo:build"/>
</schedule>
<!-- 持續(xù)集成過程的日志記錄以及需要合并的日志 -->
<log dir="logs/demo">
<!-- 合并項(xiàng)目編譯腳本中產(chǎn)生的單元、功能測(cè)試日志 -->
<merge dir="demo/target/test-reports"/>
</log>
<!-- 持續(xù)集成后結(jié)果的公布 -->
<publishers>
<currentbuildstatuspublisher file="logs/demo/buildstatus.txt"/>
<!-- 發(fā)布持續(xù)集成的結(jié)果至網(wǎng)站中,此方法還不是最理想的 -->
<execute command="D:/tools/cc/reporting/jsp/build.bat war"/>
<!-- 郵件通知相關(guān)的負(fù)責(zé)人 -->
<email mailhost="smtp.yourdomain.com"
returnaddress="buildmaster@yourdomain.com"
skipusers="true"
reportsuccess="fixes"
subjectprefix="[CruiseControl]"
buildresultsurl="http://buildserver:8080/cruisecontrol/buildresults">
<failure address="developers@yourdomain.com" />
<success address="developers@yourdomain.com" />
</email>
</publishers>
</project>
</cruisecontrol>
關(guān)于CC 的腳本中xml的規(guī)范、cc的安裝和運(yùn)行請(qǐng)參考CruiseControl的官方網(wǎng)站:
cruisecontrol.sourceforge.net