(转载)CruiseControl配置介绍

转载自:iTech的博客

一 配置文件config.xml

复制代码
<cruisecontrol>
   <property/>
   <dashboard/>
   <include.projects/>
   <system>
      <configuration>
         <threads/>
      </configuration>
   </system>
   <plugin/>
   <project>
      <property/>
      <plugin/>
      <cvslabelincrementer>
      <emptylabelincrementer>
      <formattedlabelincrementer>
      <labelincrementer/>
      <p4changelistlabelincrementer>
      <propertyfilelabelincrementer>
      <svnlabelincrementer>
      <listeners>
         <cmsynergysessionmonitor/>
         <currentbuildstatusftplistener/>
         <currentbuildstatuslistener/>
         <currentbuildstatuspagelistener/>
         <lockfilelistener/>
      </listeners>
      <bootstrappers>
         <accurevbootstrapper/>
         <alienbrainbootstrapper/>
         <antbootstrapper/>
         <clearcasebootstrapper/>
         <clearcaseviewstrapper/>
         <cmsynergybootstrapper/>
         <cmsynergybaselinebootstrapper/>
         <cvsbootstrapper/>
         <darcsbootstrapper/>
         <execbootstrapper/>
         <gitbootstrapper/>
         <harvestbootstrapper/>
         <lockfilebootstrapper/>
         <mercurialbootstrapper/>
         <p4bootstrapper/>
         <plasticscmbootstrapper/>
         <snapshotcmbootstrapper/>
         <starteambootstrapper/>
         <surroundbootstrapper/>
         <svnbootstrapper/>
         <tfsbootstrapper/>
         <vssbootstrapper/>
      </bootstrappers>
      <modificationset>
         <accurev>
         <alienbrain/>
         <alwaysbuild/>
         <buildstatus/>
         <clearcase/>
         <cmsynergy/>
         <compound>
            <targets/>
            <triggers/>
         </compound>
         <cvs/>
         <darcs/>
         <filesystem/>
         <forceonly/>
         <git/>
         <harvest/>
         <httpfile/>
         <mavensnapshotdependency/>
         <maven2snapshotdependency/>
         <mercurial/>
         <mks/>
         <p4/>
         <plasticscm/>
         <pvcs/>
         <snapshotcm/>
         <starteam/>
         <store/>
         <surround/>
         <svn/>
         <tfs/>
         <timebuild>
         <ucm>
         <veto/>
         <vss/>
         <vssjournal/>
      </modificationset>
      <schedule>
         <ant/>
         <maven/>
         <maven2/>
         <pause/>
         <nant/>
         <phing/>
         <rake/>
         <exec/>
         <composite/>
         <xcode/>
      </schedule>
      <log>
         <merge/>
     <gzip/>
     <delete/>
     <deleteartifacts/>
      </log>
      <publishers>
         <antpublisher/>
         <artifactspublisher/>
         <clearcasebaselinepublisher/>
         <cmsynergybaselinepublisher/>
         <cmsynergytaskpublisher/>
         <compoundpublisher/>
         <email/>
         <execute/>
         <ftppublisher/>
         <htmlemail/>
         <http>
         <jabber/>
         <onfailure/>
         <onsuccess/>
         <origo/>
         <rss/>
         <sametimeannouncement/>
         <scp/>
         <sfeedocman/>
         <sfeefrs/>
         <sfeetracker/>
         <socket/>
         <twitter>
         <weblog>
         <x10/>
         <xsltlogpublisher/>
         <yahoopublisher/>
      </publishers>
   </project>
</cruisecontrol>
复制代码

 

 

二 config.xml的元素<CruiseControl/>和子元素

1)<CruiseControl/>

<CruiseControl/>是配置文件的根节点,可以看做其他的元素容器。

它可以包含子元素:<system>,<project>,<plugin>,<property>,<include.projects>,<dashboard>。

2) <threads> (<system>/<configuration>/<threads>)

<threads> 用来指定CruiseControl可同时build projects的最大数目。默认为1。如果某一时刻需要运行的projects大于threads的count属性指定的值,则多余count的projects将处于等待队列。

它包含属性count。count表示thread的最大数目。

3) <property>

<property> 用来在config.xml中设置一个属性。

它可以包含属性name,value,enviroment,file,toupper。name/value用来表示一个属性;enviroment用来指定可以使用的系统环境变量的前缀,例如当environment为myenv时,表示可以使用系统中的所有的以myenv开始的环境变量,例如myenv.path;file用来加载专门包含<property/>的文件,将所有的property导入到当前config.xml;toupper用来将属性的名字转化为大写。

如下示例:

复制代码
1.Set a couple of global properties using name/value pairs: 
<cruisecontrol>
    <property name="cruisedir" value="/home/cruise"/>
    <property name="logdir"    value="${cruisedir}/logs"/>
    ...
<cruisecontrol>

2.Set a collection of global properties from the properties file "config.properties":
<cruisecontrol>
    <property file="config.properties"/>
    ...
<cruisecontrol>

3.Load the system's environment into a collection of global properties. Uppercase all environment variable names: 
<cruisecontrol>
    <property environment="env" toupper="true"/>
    <property name="logdir"     value="${env.CCDIR}/logs"/>
    ...
<cruisecontrol>

4.Define a global property called "buildmanager". Override it's value only within the scope of the project called "project2". 
<cruisecontrol>
    <property name="buildmanager" value="buildmgr@here.com"/>

    <project name="project1">
        <!-- ${buildmanager} resolves to "buildmgr@here.com" -->
    </project>

    <project name="project2">
        <property name="buildmanager" value="someoneelse@here.com"/>
        <!-- ${buildmanager} resolves to "someoneelse@here.com" -->
    </project>
<cruisecontrol>

5.As demonstrated here, properties and plugin pre-configuration can be an extremely powerful combination. 
<cruisecontrol>
    <!-- Load environment variables -->
    <property environment="env" toupper="true"/>

    <!-- Commonly used directories -->
    <property name="reportdir"  value="${env.CCDIR}/report"/>
    <property name="projectdir" value="${env.CCDIR}/checkout/${project.name}"/>
    <property name="testdir" value="${projectdir}/build/junit-reports"/>
    <property name="logdir" value="${env.CCDIR}/logs/${project.name}"/>

    <!-- Defaults for email -->
    <property name="buildmaster.email"  value="buildmaster@example.com"/>
    <property name="buildmaster.name"  value="Buildmaster"/>

    <!-- Preconfigure our plugins -->
    <plugin name="log"
            dir="${logdir}"/>

    <plugin name="currentbuildstatuslistener"
            file="${logdir}/buildstatus.html"/>

    <plugin name="cvs"
            localworkingcopy="${projectdir}"/>

    <plugin name="ant"
            antscript="${env.ANT_HOME}/bin/ant"
            antWorkingDir="${projectdir}"
            target="cruise"/>

    <plugin name="htmlemail"
            buildresultsurl="http://servername/cruisecontrol/buildresults/${project.name}"
            mailhost="smtp.example.com"
            returnaddress="${buildmaster.email}"
            returnname="${buildmaster.name}"
            subjectprefix="[BUILD ${project.name}]"
            xsldir="${reportdir}/jsp/webcontent/xsl"
            css="${reportdir}/jsp/webcontent/css/cruisecontrol.css"/>

    <project name="project1"/>
        <listeners>
            <currentbuildstatuslistener/>
        </listeners>
        <log>
            <merge dir="${testdir}">
        </log>
        <modificationset>
            <cvs/>
        </modificationset>
        <schedule>
            <ant/>
        </schedule>
        <publishers>
            <htmlemail>
                <always  address="${buildmaster.email}">
                <failure address="proj1dev@example.com">
                <ignore address="buildmaster">
            </htmlemail>
        </publishers>
    </project>

    <project name="project2"/>
        <listeners>
            <currentbuildstatuslistener/>
        </listeners>
        <log>
            <merge dir="${testdir}">
        </log>
        <modificationset>
            <cvs/>
        </modificationset>
        <schedule>
            <ant/>
        </schedule>
        <publishers>
            <htmlemail>
                <always  address="${buildmaster.email}">
                <failure address="proj2dev@example.com">
            </htmlemail>
        </publishers>
    </project>
</cruisecontrol>
复制代码

4)<include.projects>

<include.projects>用来将多个config文件合并为config文件。

它包含属性file,表示要include的config文件的相对路径。

5)<dashboard>

<dashboard>用来为build loop指定dashboard。

它包含属性url,postinterval。url为dashboard的url,postinterval表示build loop传输build信息到dashboard的间隔。

6)<project>

<project>是基本的工作单元。包含检查source修改,build,发布build结果。

它包含属性name,buildafterfailed,forcebuildnewproject,requiremodification,forceonly。buildafterfailed为ture表示即使build失败了,cruisecontrol继续保持build;forcebuildnewproject为ture表示如果没有发现project的序列文件(project.ser)就强制project开始build;requiremodification为ture表示当source code有修改时build,但是如果需要定时build或手动测试时,requiremodification需要为false。

它包含子元素<listeners>,<bootstrappers>,<modificationset>,<schedule>,<log>,<publishers>,<plugin>。

posted @ 2016-10-05 18:59  Ddddddday  阅读(156)  评论(0编辑  收藏  举报