持续集成的过程由缺省文件名为config.xml的配置文件来定义。config.xml中确定了构建周期间隔,以及检测配置库状态、调用Ant配置文件进行构建等步骤的内容。为了实现自动化持续集成,还应编制Ant封装(wrapper)配置文件,它在调用原始Ant构建脚本(相当于将原始Ant脚本封装在内)的基础上,添加用于持续集成的更新源码目录等步骤。
1.1.1 CruiseControl项目配置文件CruiseControl项目配置文件描述了一个集成项目(project),它由引导段(bootstrappers)、检测修改集段(modificationset)、调度段(schedule)、日志记录段(log)、发布段(publishers)、插件定义段(plugin)组成。引导段用来设置持续集成流程开始执行时相关的初始化任务,例如更新源码管理中的指定文件;检测修改集段则指定了需要检测的已置于配置管理下的目标源码,以便在检测到有源码更新后启动后续的构建步骤,例如clearcase中的某分支下、某视图中的一个目录;调度段是持续集成流程的核心部分,在此确定了构建周期间隔、休眠时段,并描述了构建的目标,目标通常指向一个Ant封装配置文件;日志记录段指定了将向发布步骤提供数据的各项日志记录;发布段则设置了对构建结果进行发布和通知的内容,例如指定报告的E-mail地址等;插件定义段用来指定CruiseControl各项功能实现对应的插件类。
1.1.2 CruiseControl配置文件示例下面是一个CruiseControl项目的配置文件示例:
<?xml version="1.0"?>
<cruisecontrol>
<project name="peripheral_api_project">
<bootstrappers>
<currentbuildstatusbootstrapper file="currentbuild.txt"/>
</bootstrappers>
<modificationset quietperiod="30">
<clearcase branch="PCHL_V1_Dev" recursive="true"
viewpath="d:/Shared_Views/PCHL_V1_Dev/PCHL_Components/protocols_api/peripheral"/>
</modificationset>
<schedule interval="60">
<ant buildfile="proj.xml" target="cleanbuild" multiple="5"/>
<ant buildfile="proj.xml" target="masterbuild" multiple="1"/>
<pause starttime="1900" endtime="2359"/>
<pause starttime="0000" endtime="0659"/>
<pause day="saturday" starttime="0000" endtime="2359"/>
<pause day="sunday" starttime="0000" endtime="2359"/>
</schedule>
<log dir="logs/peripheral_api_project" encoding="ISO-8859-1">
<merge dir="d:/Shared_Views/PCHL_V1_Dev/PCHL_Components/protocols_api/peripheral/bin/test-results"/>
</log>
<publishers>
<currentbuildstatuspublisher file="currentbuild.txt"/>
<email mailhost="sysway.com" returnaddress="[email protected]" defaultsuffix=""
buildresultsurl="http://pchl1-tstn:8080/cruisecontrol/buildresults" logdir="logs/peripheral_api_project"
css="C:/Development_Tools/Building-Utils/cruisecontrol-2.1.5/reporting/jsp/css/cruisecontrol.css"
xsldir="C:/Development_Tools/Building-Utils/cruisecontrol-2.1.5/reporting/jsp/xsl">
<always address="[email protected]"/>
<failure address="[email protected]"/>
<map alias="huxg" address="[email protected]"/>
</email>
</publishers>
<plugin name="currentbuildstatusbootstrapper"
classname="net.sourceforge.cruisecontrol.bootstrappers.CurrentBuildStatusBootstrapper"/>
<plugin name="clearcasebootstrapper"
classname="net.sourceforge.cruisecontrol.bootstrappers.ClearCaseBootstrapper"/>
<plugin name="clearcase" classname="net.sourceforge.cruisecontrol.sourcecontrols.ClearCase"/>
<plugin name="ant"
classname="net.sourceforge.cruisecontrol.builders.AntBuilder"/>
<plugin name="pause"
classname="net.sourceforge.cruisecontrol.PauseBuilder"/>
<plugin name="email"
classname="net.sourceforge.cruisecontrol.publishers.HTMLEmailPublisher"/>
<plugin name="currentbuildstatuspublisher"
classname="net.sourceforge.cruisecontrol.publishers.CurrentBuildStatusPublisher"/>
<plugin name="labelincrementer"
classname="net.sourceforge.cruisecontrol.labelincrementers.DefaultLabelIncrementer"/>
</project>
</cruisecontrol>
1.1.3 Ant封装(wrapper)配置文件示例
下面是一个Ant封装(wrapper)配置文件示例:
<?xml version="1.0"?>
<project name="peripheral_api_cc" default="masterbuild">
<property file="proj.properties"></property>
<property name="proj.dir" location="${proj.path}"/>
<target name="update" description="Update packages from ClearCase">
<ccupdate log="clearcase.log" overwrite="true" viewpath="${proj.dir}"/>
</target>
<target name="clean" description="Clean all build products">
<ant dir="${proj.dir}/build" target="CleanAll"/>
</target>
<target name="build">
<ant dir="${proj.dir}/build" target="AutoBuild"/>
</target>
<target name="rununittests" depends="build">
<ant dir="${proj.dir}/build" target="Test"/>
</target>
<target name="smoketest" depends="build">
</target>
<target name="masterbuild" depends="update,rununittests,smoketest"
description="Cruise control master build"/>
<target name="cleanbuild" depends="clean,masterbuild"
description="Cruise control clean build"/>
</project>
注意本Ant项目配置文件中主要添加了update目标,用来将proj.properties文件中定义的 proj.path=d:/Shared_Views/PCHL_V1_Dev/PCHL_Components/protocols_api/peripheral目录下的所有内容进行更新。
1.1.4 cruisecontrol执行示例cruisecontrol在命令行下执行的示例:
本文地址:http://com.8s8s.com/it/it37275.htm