`

CruiseControl

阅读更多

CruiseControl

本章任务

1.了解CruiseControl

 官方网址:http://cruisecontrol.sourceforge.net/

 

 官方介绍

 

CruiseControl is both a continuous integration tool and an extensible framework for creating a custom continuous build process. It includes dozens of plugins for a variety of source controls, build technologies, and notifications schemes including email and instant messaging. A web interface provides details of the current and previous builds. And the standard CruiseControl distribution is augmented through a rich selection of 3rd Party Tools.

CruiseControl is written in Java but is used on a wide variety of projects. There are builders supplied for Ant, NAnt, Maven, Phing, Rake, and Xcode, and the catch-all exec builder that can be used with any command-line tool or script.

CruiseControl is open source software and is developed and maintained by a group of dedicated volunteers. CruiseControl is distributed under a BSD-style license.

 

CruiseControl的既是一个持续集成工具,用于创建自定义生成过程中不断扩展的框架。它包括了几十个插件的源控件品种,建立技术,并通知计划,包括电子邮件和即时消息。 Web界面提供了当前和以前版本的细节。 CruiseControl的分布和标准是增强通过丰富的第三方工具的选择。

CruiseControl是Java编写的,而是基于一种广泛用于各种项目。Ant, NAnt, Maven, Phing, Rake, and Xcode供应商,并收集所有Exec的生成器,可与任何命令行工具或脚本使用。

CruiseControl是开放源码软件和开发,并有专门的志愿者群体维持。 CruiseControl支持分布式。

 

CI其实是由一系列的最佳实践所构成:
 .源代码的版本控制和管理
- 自动化构建
- 自动化测试
- 代码审查
- 自动发行和部署
- 持续反馈
使用持续集成的作用:
持续集成(CI)是一种实践,可以让团队在持续的基础 上收到反馈并进行改进,不必等到开发周期后期才寻找和修复缺陷。诸如 CruiseControl 之类的检查工具是在后台运行的,它们轮询版本控制存储库,从中寻找更改之处。当发现某一更改时,这类工具就会通过 Ant 执行预定义的构建脚本。持续检查借助持续集成的实践得以改进。 
持续集成周期包括以下几个步骤:
 1. 持续集成服务器不断从版本控制服务器上检查代码状态,看代码是否有更新。
 2. 如果发现代码有最新的提交,那么就从版本控制服务器下载最新的代码。
 3. 等代码完全更新以后,调用自动化编译脚本,进行代码编译。
 4. 运行所有的自动化测试。
 5. 进行代码分析。
 6. 产生可执行的软件,能够提供给测试人员进行测试。

 
2.配置文件包括两个,一个名为config.xml,另一个名为dashboard-config.xml。默认情况下,这两个文件和cruisecontrol.bat在同一下目录下,即工作目录

 

CruiseControl的配置文件config.xml

<cruisecontrol>
    <project name="test">--这里的name应该和你在projects目录下的项目名完全一致,且和svn里的服务名也要一致。

        <listeners> --用于监听项目状态的变化(指building,passed等)
            <currentbuildstatuslistener file="logs/${project.name}/status.txt"/>--这里的${project.name}就是test,status.txt记录当前项目的状态
        </listeners>

        <bootstrappers>--用于CruiseControl从Repository更新代码,target="ci" 对应的是build.xml里的<project name="test" basedir="." default="ci">
            <antbootstrapper anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/build.xml" target="ci" />
        </bootstrappers>

        <modificationset quietperiod="30">--用于监听在quietperiod秒内,Repository是否变化,如果有变化自动集成测试,无变化就不做任何处理
            <svn localWorkingCopy="projects/${project.name}" username="0902.aibaorong" password="aibaorong"/>--对应svn的用户名和密码
        </modificationset>

        <schedule interval="30">--用于每隔interval秒,CruiseControl去检查并计划一次构建,这里是30秒
            <ant anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/build.xml"/>
        </schedule>
        <log> --用于得到并保存log文件。默认情况下,将放在projects/${project.name}的目录下
             <merge dir="projects/${project.name}/target/test-results"/> --用于将Build中生成的结果合并
        </log>

        <publishers>--用于将构建的结果(如二进制文件)发布到指定的位置
            --决定在构建成功的情况下,发布哪些内容,这里配置的是生成javadoc,这里一般配置
            --javadoc,checkstyle,cobertura,findbugs,functiontest,javancss,jdepend,loadtest(jmeter),pmd
            <onsuccess> 
			 <artifactspublisher dest="artifacts/${project.name}" 
			dir="projects/${project.name}/cioutput/apidoc" subdirectory="javadocs" />
            </onsuccess>
        </publishers>

    </project>  
</cruisecontrol>

 

 

  CruiseControl的配置文件dashboard-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
/********************************************************************************
 * CruiseControl, a Continuous Integration Toolkit
 * Copyright (c) 2007, ThoughtWorks, Inc.
 * 200 E. Randolph, 25th Floor
 * Chicago, IL 60601 USA
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *     + Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *
 *     + Redistributions in binary form must reproduce the above
 *       copyright notice, this list of conditions and the following
 *       disclaimer in the documentation and/or other materials provided
 *       with the distribution.
 *
 *     + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
 *       names of its contributors may be used to endorse or promote
 *       products derived from this software without specific prior
 *       written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ********************************************************************************/
 -->
 <dashboard>
 	<buildloop
	    logsdir=""--这里指定logs目录,一定要与config.xml文件中一致,否则你会有麻烦。 如果为空串,则默认为工作目录下的logs目录。


      	    artifactsdir="" />--这里指定artifacts目录,一定要与config.xml文件中一致,如果为空串,则默认为工作目录下的artifacts目录。

	<features allowforcebuild=""/>--是否可以在Dashboard上强制构建(force build)

	<trackingtool projectname="" baseurl="" keywords=""/>--这是用于与Mingle的集成

 	<subtabs> --在这里,你可以自己扩展你自己的subtab页,不过要先实现一些接口。

	    <subtab class="net.sourceforge.cruisecontrol.dashboard.widgets.ErrorsAndWarningsMessagesWidget" />
	</subtabs>
</dashboard>

 

 

   CruiseControl的配置文件config.xml(官方提供的所有的属性)

  官方网址:http://cruisecontrol.sourceforge.net/main/configxml.html

<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的文档)。

<listeners> 用于监听状态变化,如waiting for build,queued,building。一般不用改变。 
<bootstrappers>用于检出代码,CruiseControl有很多种bootstrapper,示例中使用的是SVN。localWorkingCopy属性是指你把代码检出到安装CruiseControl机器的哪个文件目录。 
<modificationset>用于监听Repository的变化频率,如果CruiseControl发现代码有变化,而且在quietperiod秒内没有其它用户检入代码(用于保证被构建的版本完整性),CruiseControl才会检出代码。 
<schedule >用于指定CruiseControl去检查Repository的时间间隔。并指定使用哪个构建文件。示例中使用的是ant脚本,构建文件是被检出项目的根目录下的build.xml(即在Repository中)。 
<log>用于指定CruiseControl把日志放在哪里,把哪些构建结果放在日志中。如果没有指定任何属性,默认为logs目录下的${project.name}目录。 
<publishers> 用于在构建结束后,发布哪些消息和文件。CruiseControl有很多插件可以做各种各样的Publishing。例如,在构建成功后,通过http调用指定的页面,也可以给指定的人发邮件。在失败时,播放音乐,通知team。  

 

本章目标

1. 了解CruiseControl

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics