[CI]Starting CruiseControl

来源:互联网 发布:淘宝信用卡额度不足 编辑:程序博客网 时间:2024/05/09 01:39
这几天在学习cruisecontrol,也看了不少人的博客,把自己在入门阶段学的看的东西写在这里吧.CruiseControl(以下简称CC)自带ant,logs 下面包括日志信息,可以通过在config.xml 中指定日志路径和名称;projects 下面放的是需要进行持续集成的项目,lib 目录中放有cruisecontrol.jar 和其他运行需要的jar,webapps下是cruisecontrol build 结果的网站,可以通过访问http://127.0.0.1:8080/cruisecontrol 来查看build 的结果,个人更加喜欢先访问http://127.0.0.1:8080/,然后选择cruisecontrol或者dashboard,在build 后会产生artifacts 目录,这个目录用来存放发布的工件。
第一次启动CC之后会发现有一个默认的工程已经在projects 下了,根据这个工程的配置我们可以学到很多东西,为你自己的工程配置提供很多帮助。很多工程的配置都是类似的,举一反三就ok了,在CC根目录下的config文件是cc的配置文件,调用工程的build文件。下面是我的config文件

<!-- cruisecontrol's config.xml deploy documents in http://cruisecontrol.sourceforge.net/main/configxml.html -->
<cruisecontrol>

 <!-- we can define some parameters here -->
 <property name="artifacts" value="./artifacts" />
 
 <!--
 project name should be same as name of the folder which path is cruisecontrol/projects, buildafterfailed="false" means cc will not build if you do not update code, if buildafterfailed="true"  or you just do not define it, cc will build all along until it is correct, you will receive hundreds of e_mail one day
 -->
    <project name="CeoPhase1" buildafterfailed="false">
      <!-- monitor the change of project -->
            <listeners>
              <!-- project.name is what you define on top. In this projext, project.name = CeoPhase1 -->
                    <currentbuildstatuslistener file="logs/${project.name}/status.txt" />
            </listeners>
           
   <!-- CruiseControl update code from svn -->
            <bootstrappers>
                    <svnbootstrapper localWorkingCopy="projects/${project.name}" />
            </bootstrappers>
           
   <!-- monitor the project, if there is change, run buildfile to deploy again,
   if there is no change, do not run buildfile. There is 60 seconds, and we can not run in this 60 seconds,
   to protect svn update completely -->
            <modificationset quietperiod="60">
                    <svn localWorkingCopy="projects/${project.name}" />
            </modificationset>

   <!-- specify rebuild every 600 seconds when there is change in project-->
            <schedule interval="600">
              <!-- specify the buildfile which runs in ant -->
                    <ant anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/build.xml" >
                            <!-- set jvm argument make sure it have enough memory -->
                            <jvmarg arg="-Xms64m -Xmx512m" />
                    </ant>

            </schedule>

   <!-- specify where the logs are -->
            <log>
                    <merge dir="projects/${project.name}/report" />
            </log>
           
   <!-- publish result  -->
            <publishers>
              <!-- put war package to artifats direction when build success -->
                    <onsuccess>
                            <artifactspublisher dest="artifacts/${project.name}" file="projects/${project.name}/dist/${project.name}.war" />
                    </onsuccess>
                    <!-- sent e-mail to someone, give him(her) a link of web address -->
                    <email mailhost="mail.hengtiansoft.com" returnaddress="CruiseControl@hengtiansoft.com"
                            buildresultsurl="http://172.16.4.41:9000/cruisecontrol/buildresults/${project.name}">
                            <!-- specify send e-mail to whom when build fail -->
                            <failure address="cisco_ceocio_dev@hengtiansoft.com" />
                            <!-- specify send e-mail to whom when build success -->
                            <success address="cisco_ceocio_dev@hengtiansoft.com" />
                    </email>
            </publishers>
    </project>
   
 <project name="connectfour">

         <listeners>
              <currentbuildstatuslistener file="logs/${project.name}/status.txt"/>
          </listeners>

         <bootstrappers>
              <antbootstrapper anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/build.xml" target="clean" />
         </bootstrappers>

         <modificationset quietperiod="30">
                 <filesystem folder="projects/${project.name}"/>
         </modificationset>

         <schedule interval="3600">
              <ant anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/build.xml"/>
         </schedule>

         <log>
              <merge dir="projects/${project.name}/target/test-results"/>
         </log>

         <publishers>
              <onsuccess>
                  <artifactspublisher dest="artifacts/${project.name}" file="projects/${project.name}/target/${project.name}.jar"/>
              </onsuccess>
   <htmlemail mailhost="mail.hengtiansoft.com" returnaddress="keyongshi@hengtiansoft.com"
    buildresultsurl="http://172.16.4.41:9000/cruisecontrol/buildresults/${project.name}">
    <failure address="keyongshi@hengtiansoft.com" />
    <success address="keyongshi@hengtiansoft.com" />
   </htmlemail>

  </publishers>

 </project>

</cruisecontrol>




原创粉丝点击