【Hello CC.NET】巧用模板简化配置
從 《【Hello CC.NET】CC.NET 實(shí)現(xiàn)自動化集成》 到 《【Hello CC.NET】自動化發(fā)布時 Web.config 文件維護(hù)》 ,大神在評論里提到的方案還沒有一一去研究對比,調(diào)研的 deadline 已經(jīng)逼近,CC.NET 的落地提上日程。
經(jīng)過兩周的努力,終于成功部署了兩個項(xiàng)目,由于兩個項(xiàng)目的人員配置/開發(fā)流程/項(xiàng)目架構(gòu)不一樣,部署的方案也有些差異。過程中碰到這樣那樣的坑,都是用最快想到的笨方法填坑,然后繼續(xù)往下走。落地的姿勢并不完美,但總算有了一些看得到的成果。
落地面臨的第一個問題是,ccnet.config 配置比較繁復(fù):太多的 hardcode;相同的 xml 節(jié)點(diǎn)內(nèi)容比較多,尤其在配置多個項(xiàng)目的時候,策略變更時,需要改動的地方比較多。本文將講述 ccnet.config 模板化的思路。
目標(biāo)
- 提取全局性的配置,避免到處 Hardcode
- 簡化各個節(jié)點(diǎn)的配置,便于維護(hù)
?
1.全局變量
<cc:define CIWebSite="http://vm-caihaihua/CCNET/"/><cc:define CIDirectory="C:\CI\"/><cc:define MsBuildPath="C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"/><cc:define MsTestPath="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"/><cc:define SVNPath="C:\Program Files (x86)\VisualSVN Server\bin\svn.exe"/><cc:define FCReplacerPath="C:\CI\Tools\FCReplacer.exe"/><cc:define DFCopierPath="C:\CI\Tools\DFCopier.exe"/><cc:define name="MsBuildXmlLogger"><logger>ThoughtWorks.CruiseControl.MsBuild.XmlLogger,C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger></cc:define>
| 變量名稱 | 描述 | 值 |
| CIWebSite | CC.NET配套網(wǎng)站的地址 | http://vm-caihaihua/CCNET/ |
| CIDirectory | 工作目錄 | C:\CI\ |
| MsBuildPath | MsBuild 程序的地址 | C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe |
| MsTestPath | MsTest 程序的地址 | C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe |
| SVNPath | Svn 程序的地址 | C:\Program Files (x86)\VisualSVN Server\bin\svn.exe |
| FCReplacerPath | FCReplacer 程序的地址 | C:\CI\Tools\FCReplacer.exe |
| DFCopierPath | DFCopier 程序的地址 | C:\CI\Tools\DFCopier.exe |
| MsBuildXmlLogger | 日志 Logger 的配置 | <logger>ThoughtWorks.CruiseControl.MsBuild.XmlLogger,C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger> |
2.默認(rèn)值
<!-- 默認(rèn)配置 --><cc:define QueuePriority="1"/><cc:define KeepLastXBuilds="300"/><!-- Email 相關(guān) --><cc:define EmailDomain="company.com"/><cc:define EmailSendHost="smtp.live.com"/><cc:define EmailSendPort="25"/><cc:define EmailUseSSL="FALSE"/><cc:define EmailSendUser="ci"/><cc:define EmailSendPassword="********"/><cc:define CIEmailUser="ci"/><cc:define PMEmailUser="pm_1"/><cc:define name="EmailTesterList"><user group="tester" name="tester_1" address="tester_1@$(EmailDomain)"/><user group="tester" name="tester_2" address="tester_2@$(EmailDomain)"/></cc:define><!-- Trigger 相關(guān) --><cc:define ModificationTriggerIntervalSeconds="300"/><cc:define ModificationDelaySeconds="60"/><cc:define ProjectTriggerIntervalSeconds="30"/><cc:define ProjectTriggerStatus="Success"/><cc:define DailyBuildTriggerTime="18:00"/><!-- SVN 相關(guān) --> <cc:define SVNUsername="ci"/><cc:define SVNPassword="********"/><cc:define SvnCleanCopy="FALSE"/><cc:define name="SourceControl"> </cc:define><!-- Task 相關(guān) --><cc:define TestTimeout="1800"/><cc:define CopyTimeout="60"/><cc:define ReplaceTimeout="60"/><cc:define BuildConfiguration="DEBUG"/><cc:define PublishConfiguration="RELEASE"/>?
| 變量名稱 | 描述 | 值 |
| QueuePriority | ?項(xiàng)目在隊(duì)列中的優(yōu)先級 | ?1 |
| KeepLastXBuilds | ?保留最后的 X 個構(gòu)建結(jié)果 | ?300 |
| EmailDomain | ?公司郵箱域名 | ?company.com |
| EmailSendHost | ?郵箱服務(wù)器地址 | ?smtp.live.com |
| EmailSendPort | ?郵箱服務(wù)器端口 | ?25 |
| EmailUseSSL | ?是否啟用 SSL | ?TRUE |
| EmailSendUser | ?發(fā)送郵箱的帳號 | ?ci |
| EmailSendPassword | ?發(fā)送郵箱賬戶的密碼 | ?****** |
| ?CIEmailUser | ?CI 維護(hù)人員的郵箱賬戶 | ?ci |
| ?PMEmailUser | ?部門經(jīng)理的郵箱賬戶 | ?pm_1 |
| ?EmailTesterList | ?測試人員郵箱列表 | ?<user group="tester" name="tester_1" address="tester_1@$(EmailDomain)"/> ?<user group="tester" name="tester_2" address="tester_2@$(EmailDomain)"/> |
| ?ModificationTriggerIntervalSeconds | ?源代碼監(jiān)測的頻率(秒) | ?300 |
| ?ModificationDelaySeconds | ?源代碼變更觸發(fā)構(gòu)建任務(wù)的延遲時間(秒) | ?60 |
| ?ProjectTriggerIntervalSeconds | ?依賴項(xiàng)目的狀態(tài)監(jiān)測頻率(秒) | ?30 |
| ?ProjectTriggerStatus | ?依賴項(xiàng)目的設(shè)定狀態(tài) | ?SUCCESS |
| ?DailyBuildTriggerTime | ?每日構(gòu)建的時間點(diǎn) | ?18:00 |
| ?SVNUsername | ?SVN 帳號 | ?ci |
| ?SVNPassword | ?SVN 帳號的密碼 | ?****** |
| ?SvnCleanCopy | ?下載源代碼前是否先刪除本地源代碼 | ?FALSE |
| ?SourceControl | ?源代碼管理的配置 | ? |
| ?TestTimeout | ?運(yùn)行測試的超時時間(秒) | ?1800 |
| ?CopyTimeout | ?拷貝文件的超時時間(秒) | ?60 |
| ?ReplaceTimeout | ?替換文件內(nèi)容的超時時間(秒) | ?60 |
| ?BuildConfiguration | ?編譯的配置 | ?DEBUG |
| ?PublishConfiguration | ?發(fā)布網(wǎng)站的配置 | ?RELEASE |
3.通知模板
<cc:define name="EmailPublisher"><email mailhost="$(EmailSendHost)" mailport="$(EmailSendPort)"mailhostUsername="$(EmailSendUser)@$(EmailDomain)" mailhostPassword="$(EmailSendPassword)"from="$(EmailSendUser)@$(EmailDomain)"useSSL="$(EmailUseSSL)" includeDetails="true"><!--郵件標(biāo)題配置--><subjectPrefix>$(EmailSubject)</subjectPrefix><subjectSettings><!-- Success/Broken/StillBroken/Fixed/Exception--><subject buildResult="Success" value="${CCNetProject} Build result"/><subject buildResult="Fixed" value="${CCNetProject} Build result"/><subject buildResult="Broken" value="${CCNetProject} Build result"/><subject buildResult="StillBroken" value="${CCNetProject} Build result" /><subject buildResult="Exception" value="${CCNetProject} Build result" /></subjectSettings><!--收件人配置--><converters><rcgexConverter find="$" replace="@$(EmailDomain)"/></converters><modifierNotificationTypes><notificationType>Failed</notificationType><notificationType>Fixed</notificationType></modifierNotificationTypes><users><user group="pm" name="$(PMEmailUser)" address="$(PMEmailUser)@$(EmailDomain)"/><user group="ci" name="$(CIEmailUser)" address="$(CIEmailUser)@$(EmailDomain)"/><user group="tl" name="$(TeamLeader)" address="$(TeamLeader)@$(EmailDomain)"/><cc:EmailTesterList/></users><groups><group name="pm"><notifications><!--Always/Success/Change/Fixed/Failed/Exception --><notificationType>Change</notificationType></notifications></group><group name="ci"><notifications><notificationType>Exception</notificationType></notifications></group><group name="tl"><notifications><notificationType>Success</notificationType><notificationType>Fixed</notificationType><notificationType>Failed</notificationType></notifications></group><group name="developer"><notifications><notificationType>Success</notificationType><notificationType>Fixed</notificationType><notificationType>Failed</notificationType></notifications></group><group name="tester"><notifications><notificationType>Fixed</notificationType></notifications></group></groups></email></cc:define>?
模板變量:
| 變量名稱 | 描述 | 默認(rèn)值 | 是否必填 |
| EmailDomain | 公司郵箱域名 | ?company.com | ?N |
| EmailSendHost | 郵件服務(wù)器的地址 | ?smtp.live.com | ?N |
| EmailSendPort | 郵件服務(wù)器的端口 | ?25 | ?N |
| EmailUseSSL | 是否使用 SSL(取決于郵件服務(wù)器的配置) | ?TRUE | ?N |
| EmailSendUser | 郵件通知的發(fā)送帳號 | ?CI | ?N |
| EmailSendPassword | 郵件通知的發(fā)送帳號的密碼 | ?****** | ?N |
| PMEmailUser | 部門經(jīng)理的郵箱帳號 | ?pm_1 | ?N |
| CIEmailUser | CI 環(huán)境維護(hù)人員的郵箱帳號 | ?ci | ?N |
| TeamLeader | 項(xiàng)目組負(fù)責(zé)人的郵箱帳號,各個項(xiàng)目組配置不同 | ? | ?Y |
| EmailSubject | 郵件通知的前綴 | ? | ?Y |
? 例子:
<publishers><!--郵件通知--><cc:EmailPublisher/></publishers>?
?
? 4.觸發(fā)器模板
(1)源代碼檢測:每隔一段時間檢查源代碼,如果有變更,則觸發(fā)構(gòu)建過程
<!-- Triggers:ModificationTrigger/DailyBuildTrigger/ProjectTrigger--><cc:define name="ModificationTrigger"><!--源碼修改觸發(fā)--><intervalTrigger seconds="$(ModificationTriggerIntervalSeconds)" buildCondition="IfModificationExists" /></cc:define>?
模板變量:
| 變量名稱 | 描述 | 默認(rèn)值 | 是否必填 |
| ModificationTriggerIntervalSeconds | 源碼監(jiān)測頻率(秒) | 600 | N |
例子:
<triggers><cc:ModificationTrigger/></triggers>?
?
(2)每日構(gòu)建:每天到設(shè)定的時間點(diǎn)觸發(fā)構(gòu)建過程
<cc:define name="DailyBuildTrigger"><!--每日構(gòu)建--><scheduleTrigger time="$(DailyBuildTriggerTime)" buildCondition="ForceBuild"><weekDays><!--<weekDay>Sunday</weekDay>--><weekDay>Monday</weekDay><weekDay>Tuesday</weekDay><weekDay>Wednesday</weekDay><weekDay>Thursday</weekDay><weekDay>Friday</weekDay><!--<weekDay>Saturday</weekDay>--></weekDays></scheduleTrigger></cc:define>?
模板變量:
| 變量名稱 | 描述 | 默認(rèn)值 | 是否必填 |
| DailyBuildTriggerTime | 每日構(gòu)建的時間點(diǎn) | 18:00 | N |
例子:
<triggers><cc:DailyBuildTrigger/></triggers>?
?
(3)項(xiàng)目依賴:每隔一段時間檢查指定項(xiàng)目的構(gòu)建結(jié)果,如果等于指定值,則觸發(fā)構(gòu)建過程
<cc:define name="ProjectTrigger"><projectTrigger serverUri="tcp://vm-caihaihua:21234/CruiseManager.rem" project="$(ListenToProject)"><triggerStatus>$(ProjectTriggerStatus)</triggerStatus><innerTrigger type="intervalTrigger" seconds="$(ProjectTriggerIntervalSeconds)" buildCondition="ForceBuild" /><!--<triggerFirstTime>True</triggerFirstTime>--></projectTrigger></cc:define>?
模板變量:
| 變量名稱 | 描述 | 默認(rèn)值 | 是否必填 |
| ProjectTriggerIntervalSeconds | 監(jiān)測依賴項(xiàng)目的頻率(秒) | 30 | N |
| ProjectTriggerStatus | 設(shè)定的構(gòu)建結(jié)果 | SUCCESS | N |
| ListenToProject | 依賴的項(xiàng)目名稱 | ? | Y |
例子:
<triggers><cc:ProjectTrigger ListenToProject="TestProject-Servcies"/></triggers>?
?
5.源代碼管理模板
<!-- SourceControl: SVNSourceControl --><cc:define name="SVNSourceControl"><sourcecontrol type="svn"><trunkUrl>$(SVNTrunkURL)</trunkUrl><executable>$(SVNPath)</executable><workingDirectory>$(CIDirectory)$(WorkingDirectory)</workingDirectory><username>$(SVNUsername)</username><password>$(SVNPassword)</password><revert>True</revert><cleanCopy>$(SvnCleanCopy)</cleanCopy><cleanUp>True</cleanUp><deleteObstructions>True</deleteObstructions></sourcecontrol></cc:define>?
模板變量:
| 變量名稱 | 描述 | 默認(rèn)值 | 是否必填 |
| SVNUsername | Svn 賬戶,需要項(xiàng)目的 checkout 權(quán)限 | ci | N |
| SVNPassword | Svn 賬戶的密碼 | ****** | N |
| SvnCleanCopy | 下載源代碼前是否先刪除本地源代碼 | FALSE | N |
| SVNTrunkURL | 項(xiàng)目的 Svn 路徑 | ? | Y |
?
例子:
<project><cc:SVNSourceControl SVNTrunkURL="https://vm-caihaihua/svn/testproject/services/trunk/"SvnCleanCopy="False"/></project>?
?
6.任務(wù)模板
(1)文件內(nèi)容替換
<cc:define name="Replace"><exec><executable>$(FCReplacerPath)</executable><buildArgs><cc:Files/><cc:Rules/></buildArgs><buildTimeoutSeconds>$(ReplaceTimeout)</buildTimeoutSeconds><successExitCodes>0</successExitCodes></exec></cc:define>
?
模板變量:
| 變量名稱 | 描述 | 默認(rèn)值 | 是否必填 |
| ReplaceTimeout | 替換的超時時間(秒) | 60 | N |
| Files | 需要替換的文件列表 | ? | Y |
| Rules | 替換的規(guī)則 | ? | Y |
?
? 例子:
?
<tasks><!-- Config --><cc:Replace><cc:define name="Files"> /file=$(CIDirectory)$(WorkingDirectory)WcfService\Web.config /file=$(CIDirectory)$(WorkingDirectory)ManagerTest\App.config /file=$(CIDirectory)$(WorkingDirectory)WcfServiceTest\App.config</cc:define><cc:define name="Rules"> /from=Catalog=(?![^;\s']*_log[;\s']+)(=?[^;\s']*)/to=Catalog=testproject_trunk /from=Source=(=?.*?)(=?[;\s']+)/to=Source=vm-caihaihua$2 /from=http://(=?[^\/]+)/(=?\w+).svc/to=http://vm-caihaihua/testproject_trunk_ci/WcfService/$2.svc /from=http://(=?.*?)/(?!SSO)(=?[^\/]+)/(=?\w+).svc/to=http://vm-caihaihua/testproject_trunk_ci/WcfService/$3.svc /from=http://(=?.*?)/SSO/(=?\w+).svc/to=http://vm-caihaihua/testproject_trunk_ci/SSO/$2.svc</cc:define></cc:Replace></tasks>?
(2)項(xiàng)目編譯
<cc:define name="Build"><msbuild><executable>$(MsBuildPath)</executable><buildArgs>/t:build /p:configuration=$(BuildConfiguration)</buildArgs><cc:MsBuildXmlLogger/><workingDirectory>$(CIDirectory)$(WorkingDirectory)</workingDirectory><projectFile>$(SolutionPath)</projectFile></msbuild></cc:define>?
模板變量:
| 變量名稱 | 描述 | 默認(rèn)值 | 是否必填 |
| BuildConfiguration | 編譯的配置 | DEBUG | N |
| SolutionPath | 項(xiàng)目的相對路徑 | ? | Y |
?
? 例子:
?
<tasks><!-- Build --><cc:Build SolutionPath="TestProjectService.sln"/></tasks>?
?
(3)網(wǎng)站發(fā)布
<cc:define name="Publish"><msbuild><executable>$(MsBuildPath)</executable><workingDirectory>$(CIDirectory)$(WorkingDirectory)</workingDirectory><projectFile>$(SolutionPath)</projectFile><buildArgs>/t:ResolveReferences;Compile/t:_CopyWebApplication/p:Configuration=$(PublishConfiguration)/p:WebProjectOutputDir=$(CIDirectory)$(To)/p:OutputPath=$(CIDirectory)$(To)\bin</buildArgs></msbuild></cc:define>
?
?
模板變量:
| 變量名稱 | 描述 | 默認(rèn)值 | 是否必填 |
| PublishConfiguration | 編譯的配置 | RELACE | N |
| SolutionPath | 項(xiàng)目的相對路徑 | ? | Y |
| To | 目標(biāo)文件夾的相對路徑 | ? | Y |
?
? 例子:
<tasks><!-- Publish --><cc:Publish SolutionPath="WcfService\WcfService.csproj"To="$(PublishDirectory)WcfService" /></tasks>?
?
(4)文件拷貝
<cc:define name="Copy"><exec><executable>$(DFCopierPath)</executable><buildArgs>/from=$(CIDirectory)$(From) /to=$(CIDirectory)$(To)</buildArgs><buildTimeoutSeconds>$(CopyTimeout)</buildTimeoutSeconds><successExitCodes>0</successExitCodes></exec></cc:define>?
?
模板變量:
| 變量名稱 | 描述 | 默認(rèn)值 | 是否必填 |
| CopyTimeout | 拷貝的超時時間(秒) | 60 | N |
| From | 需要拷貝的文件夾的相對路徑 | ? | Y |
| To | 目標(biāo)文件夾的相對路徑 | ? | Y |
?
? 例子:
<tasks><!-- Copy--><cc:Copy From="$(WorkingDirectory)WcfServiceTo="$(PublishDirectory)WcfService"/></tasks>?
?
(5)自動化測試
<cc:define name="RunTest"><exec><executable>$(MSTestPath)</executable><baseDirectory>$(CIDirectory)$(WorkingDirectory)</baseDirectory><buildArgs>/testcontainer:$(TestContainerPath)</buildArgs><buildTimeoutSeconds>$(TestTimeout)</buildTimeoutSeconds></exec></cc:define>?
?
模板變量:
| 變量名稱 | 描述 | 默認(rèn)值 | 是否必填 |
| TestTimeout | 測試的超時時間(秒) | 1800 | N |
| TestContainerPath | 測試列表的相對路徑 | ? | Y |
?
? 例子:
<tasks><!--Run Test--><cc:RunTest TestContainerPath="ManagerTest\bin\Debug\ManagerTest.dll"/><cc:RunTest TestContainerPath="WcfServiceTest\bin\Debug\WcfServiceTest.dll"/></tasks>?
?
? 7.項(xiàng)目模板
<cc:define name="Project"><project name="$(ProjectName)" queue="$(Queue)" queuePriority="$(QueuePriority)"><webURL>$(CIWebSite)server/local/project/$(ProjectName)/ViewProjectReport.aspx</webURL><!--標(biāo)簽--><labeller type="dateLabeller"/><artifactDirectory>$(CIDirectory)$(ArtifactDirectory)</artifactDirectory><!--項(xiàng)目的目錄--><workingDirectory >$(CIDirectory)$(WorkingDirectory)</workingDirectory><!--自動運(yùn)行時間間隔--><triggers><cc:TriggerList/></triggers><!--對源碼修改延遲處理時間間隔--><modificationDelaySeconds>$(ModificationDelaySeconds)</modificationDelaySeconds><maxSourceControlRetries>5</maxSourceControlRetries><!--源代碼管理(SVN)--><cc:SourceControl/><state type="state" directory="$(CIDirectory)$(StateDirectory)"/><publishers><modificationHistory onlyLogWhenChangesFound="true"/><statistics/><xmllogger/><artifactcleanup cleanUpMethod="KeepLastXBuilds" cleanUpValue="$(KeepLastXBuilds)" /><!--郵件通知--><cc:EmailPublisher/></publishers><tasks><cc:TaskList/></tasks></project></cc:define>?
?
模板變量:
| 變量名稱 | 描述 | 默認(rèn)值 | 是否必填 |
| QueuePriority | 項(xiàng)目在隊(duì)列里的優(yōu)先級 | 1 | N |
| KeepLastXBuilds | 保存最后的 X 個構(gòu)建結(jié)果 | 300 | N |
| ModificationDelaySeconds | 源代碼變更觸發(fā)構(gòu)建任務(wù)的延遲時間 | 60 | N |
| SourceControl | 源代碼配置 | ? | N |
| Queue | 項(xiàng)目從屬的隊(duì)列 | ? | Y |
| ProjectName | 項(xiàng)目名稱 | ? | Y |
| StateDirectory | 構(gòu)建日志的保存目錄 | ? | Y |
| WorkingDirectory | 項(xiàng)目的工作目錄,即源代碼的保存路徑 | ? | Y |
| ArtifactDirectory | 構(gòu)建結(jié)果的存放目錄 | ? | Y |
| TriggerList | 觸發(fā)器配置列表 | ? | Y |
| TaskList | 任務(wù)列表 | ? | Y |
? 例子:
TestProject 包括 Wcf Service 項(xiàng)目和 AdminWeb 項(xiàng)目
(1)Wcf Service
a.??自動化部署
-
- 自動獲取源代碼
- 源代碼監(jiān)測及每日構(gòu)建
- 修改配置文件中的數(shù)據(jù)庫連接字符串及服務(wù)引用地址
- Debug 編譯整個解決方案
- Release 發(fā)布 Service 到 CI 環(huán)境
b.?自動化測試
-
- 與a使用同一個工作目錄(即源代碼)
- 監(jiān)測自動化部署過程,如果成功則觸發(fā)自動化測試
- 運(yùn)行 ManagerTest 和 ServiceTest
(2) AdminWeb
自動化部署
- 自動獲取源代碼
- 源代碼監(jiān)測及每日構(gòu)建
- 修改配置文件中的數(shù)據(jù)庫連接字符串及服務(wù)引用地址
- Debug 編譯整個解決方案
- Release 發(fā)布 AdminWeb 到 CI 環(huán)境
?
完整的 ccnet.config:
<cruisecontrol xmlns:cc="urn:ccnet.config.builder"><!-- 全局配置 --><cc:define CIWebSite="http://vm-caihaihua/CCNET/"/><cc:define CIDirectory="C:\CI\"/><cc:define MsBuildPath="C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"/><cc:define MsTestPath="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"/><cc:define SVNPath="C:\Program Files (x86)\VisualSVN Server\bin\svn.exe"/><cc:define FCReplacerPath="C:\CI\Tools\FCReplacer.exe"/><cc:define DFCopierPath="C:\CI\Tools\DFCopier.exe"/><cc:define name="MsBuildXmlLogger"><logger>ThoughtWorks.CruiseControl.MsBuild.XmlLogger,C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger></cc:define><!-- Publishers:EmailPublisher--><cc:define name="EmailPublisher"><email mailhost="$(EmailSendHost)" mailport="$(EmailSendPort)"mailhostUsername="$(EmailSendUser)@$(EmailDomain)" mailhostPassword="$(EmailSendPassword)"from="$(EmailSendUser)@$(EmailDomain)"useSSL="$(EmailUseSSL)" includeDetails="true"><!--郵件標(biāo)題配置--><subjectPrefix>$(EmailSubject)</subjectPrefix><subjectSettings><!-- Success/Broken/StillBroken/Fixed/Exception--><subject buildResult="Success" value="${CCNetProject} ${CCNetBuildDate} Build result"/><subject buildResult="Fixed" value="${CCNetProject} ${CCNetBuildDate} Build result"/><subject buildResult="Broken" value="${CCNetProject} ${CCNetBuildDate} Build result"/><subject buildResult="StillBroken" value="${CCNetProject} ${CCNetBuildDate} Build result" /><subject buildResult="Exception" value="${CCNetProject} ${CCNetBuildDate} Build result" /></subjectSettings>lo<!--收件人配置--><converters><regexConverter find="$" replace="@$(EmailDomain)"/></converters><modifierNotificationTypes><notificationType>Failed</notificationType><notificationType>Fixed</notificationType></modifierNotificationTypes><users><user group="pm" name="$(PMEmailUser)" address="$(PMEmailUser)@$(EmailDomain)"/><user group="ci" name="$(CIEmailUser)" address="$(CIEmailUser)@$(EmailDomain)"/><user group="tl" name="$(TeamLeader)" address="$(TeamLeader)@$(EmailDomain)"/><cc:EmailTesterList/></users><groups><group name="pm"><notifications><!--Always/Success/Change/Fixed/Failed/Exception --><notificationType>Change</notificationType></notifications></group><group name="ci"><notifications><notificationType>Exception</notificationType></notifications></group><group name="tl"><notifications><notificationType>Success</notificationType><notificationType>Fixed</notificationType><notificationType>Failed</notificationType></notifications></group><group name="developer"><notifications><notificationType>Success</notificationType><notificationType>Fixed</notificationType><notificationType>Failed</notificationType></notifications></group><group name="tester"><notifications><notificationType>Fixed</notificationType></notifications></group></groups></email></cc:define><!-- Triggers:ModificationTrigger/DailyBuildTrigger/ProjectTrigger--><cc:define name="ModificationTrigger"><!--源碼修改觸發(fā)--><intervalTrigger seconds="$(ModificationTriggerIntervalSeconds)" buildCondition="IfModificationExists" /></cc:define><cc:define name="DailyBuildTrigger"><!--每日構(gòu)建--><scheduleTrigger time="$(DailyBuildTriggerTime)" buildCondition="ForceBuild"><weekDays><!--<weekDay>Sunday</weekDay>--><weekDay>Monday</weekDay><weekDay>Tuesday</weekDay><weekDay>Wednesday</weekDay><weekDay>Thursday</weekDay><weekDay>Friday</weekDay><!--<weekDay>Saturday</weekDay>--></weekDays></scheduleTrigger></cc:define><cc:define name="ProjectTrigger"><projectTrigger serverUri="tcp://Server12:21234/CruiseManager.rem" project="$(ListenToProject)"><triggerStatus>$(ProjectTriggerStatus)</triggerStatus><innerTrigger type="intervalTrigger" seconds="$(ProjectTriggerIntervalSeconds)" buildCondition="ForceBuild" /><!--<triggerFirstTime>True</triggerFirstTime>--></projectTrigger></cc:define><!-- SourceControl: SVNSourceControl --><cc:define name="SVNSourceControl"><sourcecontrol type="svn"><trunkUrl>$(SVNTrunkURL)</trunkUrl><executable>$(SVNPath)</executable><workingDirectory>$(CIDirectory)$(WorkingDirectory)</workingDirectory><username>$(SVNUsername)</username><password>$(SVNPassword)</password><revert>True</revert><cleanCopy>$(SvnCleanCopy)</cleanCopy><cleanUp>True</cleanUp><deleteObstructions>True</deleteObstructions></sourcecontrol></cc:define><!-- Tasks: Replace/Build/Publish/Copy/RunTest --><cc:define name="Replace"><exec><executable>$(FCReplacerPath)</executable><buildArgs><cc:Files/><cc:Rules/></buildArgs><buildTimeoutSeconds>$(ReplaceTimeout)</buildTimeoutSeconds><successExitCodes>0</successExitCodes></exec></cc:define><cc:define name="Build"><msbuild><executable>$(MsBuildPath)</executable><buildArgs>/t:build /p:configuration=$(BuildConfiguration)</buildArgs><cc:MsBuildXmlLogger/><workingDirectory>$(CIDirectory)$(WorkingDirectory)</workingDirectory><projectFile>$(SolutionPath)</projectFile></msbuild></cc:define><cc:define name="Publish"><msbuild><executable>$(MsBuildPath)</executable><workingDirectory>$(CIDirectory)$(WorkingDirectory)</workingDirectory><projectFile>$(SolutionPath)</projectFile><buildArgs>/t:ResolveReferences;Compile/t:_CopyWebApplication/p:Configuration=$(PublishConfiguration)/p:WebProjectOutputDir=$(CIDirectory)$(To)/p:OutputPath=$(CIDirectory)$(To)\bin</buildArgs></msbuild></cc:define><cc:define name="Copy"><exec><executable>$(DFCopierPath)</executable><buildArgs>/from=$(CIDirectory)$(From) /to=$(CIDirectory)$(To)</buildArgs><buildTimeoutSeconds>$(CopyTimeout)</buildTimeoutSeconds><successExitCodes>0</successExitCodes></exec></cc:define><cc:define name="RunTest"><exec><executable>$(MSTestPath)</executable><baseDirectory>$(CIDirectory)$(WorkingDirectory)</baseDirectory><buildArgs>/testcontainer:$(TestContainerPath)</buildArgs><buildTimeoutSeconds>$(TestTimeout)</buildTimeoutSeconds></exec></cc:define><!-- 通用配置(模板) --><cc:define name="Project"><project name="$(ProjectName)" queue="$(Queue)" queuePriority="$(QueuePriority)"><webURL>$(CIWebSite)server/local/project/$(ProjectName)/ViewProjectReport.aspx</webURL><!--標(biāo)簽--><labeller type="dateLabeller"/><artifactDirectory>$(CIDirectory)$(ArtifactDirectory)</artifactDirectory><!--項(xiàng)目的目錄--><workingDirectory >$(CIDirectory)$(WorkingDirectory)</workingDirectory><!--自動運(yùn)行時間間隔--><triggers><cc:TriggerList/></triggers><!--對源碼修改延遲處理時間間隔--><modificationDelaySeconds>$(ModificationDelaySeconds)</modificationDelaySeconds><maxSourceControlRetries>5</maxSourceControlRetries><!--源代碼管理(SVN)--><cc:SourceControl/><state type="state" directory="$(CIDirectory)$(StateDirectory)"/><publishers><modificationHistory onlyLogWhenChangesFound="true"/><statistics/><xmllogger/><artifactcleanup cleanUpMethod="KeepLastXBuilds" cleanUpValue="$(KeepLastXBuilds)" /><!--郵件通知--><cc:EmailPublisher/></publishers><tasks><cc:TaskList/></tasks></project></cc:define><!-- 默認(rèn)配置 --><cc:define QueuePriority="1"/><cc:define KeepLastXBuilds="300"/><!-- Email 相關(guān) --><cc:define EmailDomain="company.com"/><cc:define EmailSendHost="smtp.live.com"/><cc:define EmailSendPort="25"/><cc:define EmailUseSSL="TRUE"/><cc:define EmailSendUser="ci"/><cc:define EmailSendPassword="******"/><cc:define CIEmailUser="ci"/><cc:define PMEmailUser="pm_1"/><cc:define name="EmailTesterList"><user group="tester" name="tester_1" address="tester_1@$(EmailDomain)"/><user group="tester" name="tester_2" address="tester_2@$(EmailDomain)"/></cc:define><!-- Trigger 相關(guān) --><cc:define ModificationTriggerIntervalSeconds="300"/><cc:define ModificationDelaySeconds="60"/><cc:define ProjectTriggerIntervalSeconds="30"/><cc:define ProjectTriggerStatus="SUCCESS"/><cc:define DailyBuildTriggerTime="18:00"/><!-- SVN 相關(guān) --> <cc:define SVNUsername="ci"/><cc:define SVNPassword="******"/><cc:define SvnCleanCopy="FALSE"/><cc:define name="SourceControl"> </cc:define><!-- Task 相關(guān) --><cc:define TestTimeout="1800"/><cc:define CopyTimeout="60"/><cc:define ReplaceTimeout="60"/><cc:define BuildConfiguration="DEGUB"/><cc:define PublishConfiguration="RELEASE"/><!-- TestProject: Service 項(xiàng)目 --><queue name="TestProject" duplicates="ApplyForceBuildsReAdd" /><cc:Project ProjectName="TestProject-Servcies"Queue="TesProjectt"WorkingDirectory="TestProject\SourceCode\service_trunk\"ArtifactDirectory="TestProject\Artifact\service\"StateDirectory="TestProject\State\"PublishDirectory="TestProject\Publish\"EmailSubject="[CI-TestProjectService]"ModificationDelaySeconds="30"TeamLeader="caihaihua"><cc:define name="SourceControl"><cc:SVNSourceControl SVNTrunkURL="https://vm-caihaihua/svn/testproject/services/trunk/"SvnCleanCopy="False"/></cc:define><cc:define name="TriggerList"><cc:ModificationTrigger/><cc:DailyBuildTrigger/></cc:define><cc:define name="TaskList"><!-- Config --><cc:Replace><cc:define name="Files">/file=$(CIDirectory)$(WorkingDirectory)WcfService\Web.config/file=$(CIDirectory)$(WorkingDirectory)ManagerTest\App.config/file=$(CIDirectory)$(WorkingDirectory)WcfServiceTest\App.config</cc:define><cc:define name="Rules">/from=Catalog=(?![^;\s']*_log[;\s']+)(=?[^;\s']*)/to=Catalog=service_trunk_ci/from=Source=(=?.*?)(=?[;\s']+)/to=Source=localhost$2/from=http://(=?[^\/]+)/(=?[^\/]+).svc/to=http://vm-caihaihua/testproject_trunk_ci/WcfService/$2.svc/from=http://(=?.*?)/(?!SSO)(=?[^\/]+)/(=?[^\/]+).svc/to=http://vm-caihaihua/testproject_trunk_ci/WcfService/$3.svc/from=http://(=?.*?)/SSO/(=?[^\/]+).svc/to=http://vm-caihaihua/testproject_trunk_ci/SSO/$2.svc</cc:define></cc:Replace><!-- Build --><cc:Build SolutionPath="TestProjectService.sln"/><!-- Publish --><cc:Copy From="$(WorkingDirectory)WcfService"To="$(PublishDirectory)WcfService"/></cc:define></cc:Project><cc:Project ProjectName="TestProjectServcies-Test"Queue="TestProject"QueuePriority="2"WorkingDirectory="TestProject\SourceCode\service_trunk\"ArtifactDirectory="TestProject\Artifact\test\"StateDirectory="TestProject\State\"EmailSubject="[CI-TestProjectServcie-Test]"ModificationDelaySeconds="30"TeamLeader="caihaihua"><cc:define name="TriggerList"><cc:ProjectTrigger ListenToProject="TestProject-Servcies"/></cc:define><cc:define name="TaskList"><!--Run Test--><cc:RunTest TestContainerPath="ManagerTest\bin\Debug\ManagerTest.dll"/><cc:RunTest TestContainerPath="WcfServiceTest\bin\Debug\WcfServiceTest.dll"/></cc:define></cc:Project><!-- TestProject: AdminWeb 項(xiàng)目 --><cc:Project ProjectName="TestProject-AdminWeb"Queue="TestProject"WorkingDirectory="TestProject\SourceCode\admin_trunk\"ArtifactDirectory="TestProject\Artifact\admin\"StateDirectory="TestProject\State\"PublishDirectory="TestProject\Publish\"EmailSubject="[CI-TestProject-AdminWeb]"TeamLeader="caihaihua"><cc:define name="SourceControl"><cc:SVNSourceControl SVNTrunkURL="https://vm-caihaihua/svn/testproject/adminweb/trunk/"/></cc:define><cc:define name="TriggerList"><cc:ModificationTrigger/><cc:DailyBuildTrigger/></cc:define><cc:define name="TaskList"><!-- Config --><cc:Replace><cc:define name="Files">/file=$(CIDirectory)$(WorkingDirectory)AdminWeb\Web.config</cc:define><cc:define name="Rules">/from=http://(=?[^\/]+)/(=?[^\/]+).svc/to=http://vm-caihaihua/testproject_trunk_ci/WcfService/$2.svc/from=http://(=?.*?)/(?!SSO)(=?[^\/]+)/(=?[^\/]+).svc/to=http://vm-caihaihua/testproject_trunk_ci/WcfService/$3.svc/from=http://(=?.*?)/SSO/(=?[^\/]+).svc/to=http://vm-caihaihua/testproject_trunk_ci/SSO/$2.svc</cc:define></cc:Replace><!-- Build --><cc:Build SolutionPath="AdminWeb.sln"/><!-- Publish --><cc:Publish SolutionPath="AdminWeb\AdminWeb.csproj"To="$(PublishDirectory)AdminWeb" /></cc:define></cc:Project> </cruisecontrol> View Code?
?
轉(zhuǎn)載于:https://www.cnblogs.com/harveyChoi/p/hello_cc_net_3.html
總結(jié)
以上是生活随笔為你收集整理的【Hello CC.NET】巧用模板简化配置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 开启Apache mod_rewrite
- 下一篇: zoj 3351 Bloodsucker