CruiseControl.NET简介
CruiseControl.NET是.net平台下,一个开源的自动化持续集成工具。 它是一个程序套件,但其核心是一个叫做CruiseControl.NET Server的自动集成服务器.
通过直接监视源代码管理仓库,CruiseControl.NET使集成过程得以自动化。开发员每提交一组新的更新,CruiseControl.NET Server就会自动运行集成构造,以验证新的更新。当构造完成以后,Server将会通知开发员,提交的更改是否成功通过集成。事实上,集成同签入(Check in)代码一样容易。使用自动集成服务器不仅仅使集成变得容易,它还会保证一旦有更新,集成构造一定会发生。这将有效降低在开发员签入(Check in)代码之后,忘记代码有效性验证的危险。
1.配置项目
<!--name:项目名称;queue:采用何种序列处理方式;queuePriority:序列的优先级-->
<project name="Project 1" queue="Q1" queuePriority="1"><!--工作目录的配置,设定一个绝对路径作为集成的工作目录-->
<workingDirectory>yourWorkingDirectory</workingDirectory>
<!--集成结果保存路径,每个项目配置一个唯一路径-->
<artifactDirectory>yourArtifactDirectory</artifactDirectory>
<!--web界面集成报告的URL,这个URL一般用在邮件内容中-->
<webURL>http://localhost/ccnet</webURL>
<!--源代码迁入与启动集成的最少时间间隔-->
<modificationDelaySeconds>2</modificationDelaySeconds>
<!--触发模式,一般采用间隔触发器-->
<triggers>
<!--name:触发器名称;seconds:间隔时间;BuildCondition:构建条件,有两个选项——强制集成ForceBuild和文件变动时集成IfModificationExists;initialSeconds:server启动与第一次构建的时间间隔-->
<intervalTrigger name="continuous" seconds="30" buildCondition="ForceBuild" initialSeconds="30"/>
</triggers>
</project>
2.配置源代码管理
<sourcecontrol type="svn">
<!--源代码的svn路径-->
<project> XXXXX/code/branches/MEMS_AllSource</project>
<!--SVN用户名-->
<username>svnname </username>
<!--SVN密码-->
<password>svnpws</password>
<!--工作目录,可以使用相对目录,以上面的workingDirectory为准-->
<workingDirectory>D:\CCPro\mywork</workingDirectory>
</sourcecontrol>
3.配置编译
<msbuild>
<!--MSBuild的路径-->
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<!--工作路径-->
<workingDirectory>C:\dev\ccnet</workingDirectory>
<!--解决方案或项目sln文件-->
<projectFile>CCNet.sln</projectFile>
<!--MSBuild的构建参数-->
<buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>
<!--构建目标-->
<targets>Build</targets>
<!--超时时间-->
<timeout>900</timeout>
<!--日志文件处理模快-->
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
4.配置邮件提醒
<!--from:邮件发件人;mailhost:邮件服务器地址;mailport:smtp端口;includeDetail:是否包含详细报告信息;mailhostUsername:smtp用户名;mailhostPassword:smtp密码;useSSL:是否使用ssl发送邮件-->
<email from="buildmaster@mycompany.com" mailhost="smtp.mycompany.com" mailport="25" includeDetails="TRUE"
mailhostUsername="smtpuser" mailhostPassword="smtppassword" useSSL="FALSE">
<!--定义一组接收邮件的用户-->
<users>
<!--name:用户名称,必须同源代码管理系统的帐号一致;group:所属分组;address:邮件地址;-->
<user name="BuildGuru" group="buildmaster" address="buildguru@mycompany.com"/>
<user name="JoeDeveloper" group="developers" address="joedeveloper@thoughtworks.com"/>
</users>
<!--用户组-->
<groups>
<!--name:组名称;nitification:通知策略——Always[每次构建均发送通知]、Changed[构建结果发生改变时发送通知,例如从success变为fail]、Failed[当构建失败时发送通知]、Success[当构建成功时发送通知]、Fixed[当构建从失败到通知时发送通知]、Exception[构建发生异常时发送通知]-->
<group name="developers" notification="change"/>
<group name="buildmaster" notification="always"/>
</groups>
<!--设置提交者通知测略,当构建完成后,符合符合设置的条件将邮件通知所有此次源代码改变的参与者-->
<modifierNotificationTypes>
<NotificationType>Failed</NotificationType>
<NotificationType>Fixed</NotificationType>
</modifierNotificationTypes>
</email>
部署实例
<?xml version="1.0" encoding="utf-8"?>
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<!-- This is your CruiseControl.NET Server Configuration file. Add your projects below! --><project name="myproject" >
<workingDirectory>D:\ccnet</workingDirectory>
<artifactDirectory>D:\ccnet</artifactDirectory>
<labeller type="dateLabeller" />
<sourcecontrol type="svn">
<autoGetSource>true</autoGetSource>
<!--源码库中的项目名称,SVN中源代码的路径-->
<trunkUrl>https://XXXXXXXXXX/code/branches/MEMS_AllSource</trunkUrl><!--SVN命令客户端安装文件安装的所有目录-->
<executable>C:\Program Files\CollabNet\Subversion Client\svn.exe</executable>
<!--svn用户名-->
<username>username</username>
<!--svn密码-->
<password>userpws</password>
<!--工作目录,可以使用相对目录,以上面的workingDirectory为准-->
<workingDirectory>D:\CCPro\myproject</workingDirectory>
</sourcecontrol>
<triggers>
<!--定时任务,可以设置在哪天的那个时间执行构建计划-->
<scheduleTrigger time="21:00" buildCondition="ForceBuild">
<!--以下配置节有指定,则会在指定的时间日期内执行,没有则每天执行-->
<!--<weekDays>
<weekDay>Monday</weekDay>
</weekDays>-->
</scheduleTrigger>
<!--每隔多少时间执行一次-->
<!--每天21:30-23:59以及00:00-08:20不执行-->
<filterTrigger startTime="21:30" endTime="08:20">
<!--每隔多少时间执行一次-->
<trigger type = "intervalTrigger" name="continuous" seconds="30" buildCondition="IfModificationExists" initialSeconds="60" />
</filterTrigger></triggers>
<tasks><!--msbuild 自动编译任务-->
<msbuild>
<!--msbuild的路径,一般在系统目录下-->
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>D:\CCPro\myproject</workingDirectory>
<!--解决方案文件,相对project 的workingDirectory,MSBuild会找到这个文件,并对它进行编译-->
<projectFile>D:\CCPro\my2641\MEMS_AllSource.sln</projectFile>
<!--编译参数-->
<!--<buildArgs></buildArgs>-->
<!--编译的目录类型-->
<!--<targets></targets>-->
<!--过期时间-->
<timeout>1800</timeout>
<!--记录编译的详细日志,需要单独下载这个程序集,放在工作目录(workingDirectory)下,下载路径http://ccnetlive.thoughtworks.com/MSBuildXmlLogger%2DBuilds/-->
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>
<!--<logger>ThoughtWorks.CruiseControl.MsBuild.XmlLogger,ThoughtWorks.CruiseControl.MsBuild.dll</logger>--></msbuild>
</tasks>
<publishers>
<xmllogger logDir="D:\ccnet\buildlogs" />
<email mailport="25" includeDetails="TRUE" mailhostUsername="aaa@163.com" mailhostPassword="*******" useSSL="FALSE">
<from>aaa@163.com</from>
<mailhost>smtp.163.com</mailhost>
<users>
<user name="Ailsa" group="tester" address="Ailsa@163.com"/><user name="朱朱" group="developer" address="zz@163.com" />
</users>
<groups>
<group name="tester">
<notifications>
<notificationType>Failed</notificationType>
<notificationType>Fixed</notificationType>
</notifications></group>
<group name="developer">
<notifications>
<notificationType>Failed</notificationType>
<notificationType>Fixed</notificationType>
</notifications>
</group>
<group name="buildmaster">
<notifications>
<notificationType>Exception</notificationType>
</notifications>
</group>
</groups>
<!--
<converters>
<regexConverter find="$" replace="@TheCompany.com" />
</converters>-->
<modifierNotificationTypes>
<NotificationType>Failed</NotificationType>
<NotificationType>Fixed</NotificationType>
</modifierNotificationTypes>
<subjectSettings>
<subject buildResult="StillBroken" value="Build is still broken for ${CCNetProject},the fix failed." />
<subject buildResult="Broken" value="${CCNetProject} broke at ${CCNetBuildDate} ${CCNetBuildTime } , last checkin(s) by ${CCNetFailureUsers}" />
<subject buildResult="Exception" value="Serious problem for ${CCNetProject}, it is now in Exception! Check status of network / sourcecontrol" />
<subject buildResult="Fixed" value="${CCNetProject} is fixed now! last checkin(s) by ${CCNetFailureUsers}.Well done!" />
</subjectSettings>
<xslFiles>
<file>xsl\header.xsl</file>
<file>xsl\compile.xsl</file>
<file>xsl\unittests.xsl</file>
<file>xsl\modifications.xsl</file>
<xslFile>xsl\compile-msbuild.xsl</xslFile>
</xslFiles>
<!--
<attachments>
<file>C:\Data\AFile.txt</file>
<file>Relative.txt</file>
</attachments>
-->
</email>