CruiseControl.Net学习记录
一、下载
二、安装
本文版本:1.8.5.0
运行安装程序,按照提示"下一步”,直到完成即可。
安装完毕之后,
生成一个windows服务,CruiseControl.NET Server ;
生成一个webdashboard网站(可自行在IIS中配置)。
三、启动
在服务管理控制台,启动服务CruiseControl.NET Server;也可以不启动windows服务,而采用ccnet.exe控制台程序,需以管理员身份运行。
在IIS中配置启动webdashboard站点。
四、配置
在server目录中的ccnet.config文件中进行项目配置。
github(git协议)
1 <cruisecontrol xmlns:cb="urn:ccnet.config.builder"> 2 3 <project name="ccnet.test" description="ccnet.test"> 4 <!--项目编译状态信息的保存位置--> 5 <state type="state" directory="E:\CCNet\State" /> 6 <!--对这个项目的监控过程的日志记录目录--> 7 <artifactDirectory>E:\CCNet\BuildArtifacts\ccnet.test</artifactDirectory> 8 <!--源代码控制系统--> 9 <sourcecontrol type="git"> 10 <repository>git://github.com/shashoutian/ccnet.test.git</repository> 11 <branch>master</branch> 12 <executable>E:\ProgramFiles\Git\cmd\git.exe</executable> 13 <committerName>shashoutian</committerName> 14 <committerEMail>shashoutian2008@126.com</committerEMail> 15 <workingDirectory>D:\Projects\GitProjects\ccnet.test</workingDirectory> 16 </sourcecontrol> 17 <!--配置具体执行的任务--> 18 <tasks> 19 <exec> 20 <!-- if you want the task to fail, ping an unknown server --> 21 <executable>ping.exe</executable> 22 <buildArgs>localhost</buildArgs> 23 <buildTimeoutSeconds>15</buildTimeoutSeconds> 24 <description>Pinging a server</description> 25 </exec> 26 27 <!--msbuild任务配置,用来编译项目--> 28 <msbuild> 29 <!--MSBuild.exe的路径--> 30 <executable>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable> 31 <!--源代码的存放位置,不配置的时候为默认值 --> 32 <workingDirectory>D:\Projects\GitProjects\ccnet.test\CCNet.Test</workingDirectory> 33 <!--要编译的项目名称 --> 34 <projectFile>CCNet.Test.sln</projectFile> 35 <!-- MSBuild编译时的参数,具体参数信息可以查看MSDN上的说明--> 36 <buildArgs>/p:VisualStudioVersion=14.0;Configuration=Debug;OutputPath=E:\Publish\ccnet.test /v:diag</buildArgs> 37 <!--编译目标--> 38 <targets>Build</targets> 39 <!--超时时间--> 40 <timeout>900</timeout> 41 <!--日志记录模块--> 42 <logger>E:\ProgramFiles\CCNet\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger> 43 </msbuild> 44 45 <!--发布和部署配置--> 46 <buildpublisher> 47 <sourceDir>E:\Publish\ccnet.test\_PublishedWebsites\CCNet.Test</sourceDir> 48 <publishDir>E:\Publish\ccnet.test\_PublishedWebsites\CCNet.Test</publishDir> 49 <useLabelSubDirectory>false</useLabelSubDirectory> 50 <alwaysPublish>false</alwaysPublish> 51 </buildpublisher> 52 </tasks> 53 </project> 54 55 </cruisecontrol>
gitlab(ssh协议)
1 <cruisecontrol xmlns:cb="urn:ccnet.config.builder"> 2 <!-- This is your CruiseControl.NET Server Configuration file. 3 Add your projects below! --> 4 <project name="Disney" description="Disney ManageWeb"> 5 <!--分类--> 6 <category>后台系统</category> 7 <!--日志目录--> 8 <state type="state" directory="C:\CCNet\State" /> 9 <artifactDirectory>C:\CCNet\BuildArtifacts\Disney</artifactDirectory> 10 <!--源码控制--> 11 <sourcecontrol type="git"> 12 <repository>git@gitlab.mtime-dev.com:partner/disney-mw.git</repository> 13 <branch>develop</branch> 14 <executable>C:\Program Files (x86)\Git\cmd\git.exe</executable> 15 <workingDirectory>D:\GitProjects\partner\abc</workingDirectory> 16 </sourcecontrol> 17 <!--任务--> 18 <tasks> 19 <exec> 20 <!-- if you want the task to fail, ping an unknown server --> 21 <executable>ping.exe</executable> 22 <buildArgs>localhost</buildArgs> 23 <buildTimeoutSeconds>15</buildTimeoutSeconds> 24 <description>Pinging a server</description> 25 </exec> 26 <!--编译项目--> 27 <msbuild> 28 <executable>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe</executable> 29 <workingDirectory>D:\GitProjects\partner\abc\Disney.Manage.Web</workingDirectory> 30 <projectFile>Disney.Manage.Web.csproj</projectFile> 31 <logger>E:\ccnet\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger> 32 <targets>Build</targets> 33 <timeout>900</timeout> 34 <!--/p 最后一对属性值后面不需要分号(切记)--> 35 <buildArgs>/p:OutputPath=E:\BuildOutput\disney;Configuration=Release;Platform=AnyCPU</buildArgs> 36 </msbuild> 37 <!--发布到站点--> 38 <buildpublisher> 39 <sourceDir>E:\BuildOutput\disney</sourceDir> 40 <publishDir>E:\websites\disney\</publishDir> 41 <useLabelSubDirectory>false</useLabelSubDirectory> 42 </buildpublisher> 43 </tasks> 44 <publishers> 45 <xmllogger /> 46 <artifactcleanup cleanUpMethod="KeepLastXBuilds" cleanUpValue="50" /> 47 </publishers> 48 </project> 49 </cruisecontrol>
五、配置节点详解
六、需要注意的问题
1、ccnet的webdashboard站点基于.net2.0运行;
2、ccnet通过git控制源代码时,需要首先确保在cmd命令行中可以执行git的各个命令,即需要配置环境变量Path:安装目录\Git\cmd,如 E:\ProgramFiles\Git\cmd;
3、使用github时,在ccnet.config中sourcecontrol节点的repository需采用git协议,而不是http协议和ssh协议,并且git协议获取的文件是只读的(待确认);如
<repository>git://github.com/shashoutian/ccnet.test.git</repository>
七、参考资料
每日集成CruiseControl.NET + SVN + Msbuild + NAnt
项目管理实践三、每日构建【Daily Build Using CruiseControl.NET and MSBuild】