posts - 56, comments - 77, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理
          ©Copyright 2007 Julian Simpson. All rights reserved.

          英文原文:   CruiseControl Enterprise: 10 Best Practices

          I'm an Infrastructure Specialist at ThoughtWorks.  In my role I make sure that we are building our software so it can successfully be deployed to production.  In this series of blog posts I hope to pass on my top ten tips for using CruiseControl Enterprise effectively.  I'm writing these with the developers or systems administrators in mind: the people who most often manage CruiseControl.  However, I hope that anybody who is interested in Continuous Integration will get something from these articles.

          # 1: Publish with a Publisher : 使用 Publisher 來發(fā)布, 而不是在構(gòu)建過程中發(fā)布

          許多項目都會用到"發(fā)布"的概念:  把構(gòu)建產(chǎn)物放到指定地方, 或者把測試結(jié)果發(fā)送給最終用戶.  ArtifactsPublisher 就是一種很常用的方式, 用來把文件發(fā)布到CruiseControl自己的時間戳目錄形式的倉庫中, 這樣構(gòu)建日志, 構(gòu)建產(chǎn)物和測試結(jié)果等就可以通過新的CruiseControl Dashboard或者傳統(tǒng)的CruiseControl Reporting應(yīng)用展現(xiàn)出來.

           ArtifactsPublisher不過是整個 Publisher 家族中的一員, 而我的最愛是 AntPubliisher.  如果你的Ant構(gòu)建以發(fā)布構(gòu)建產(chǎn)物到倉庫中或者給你的版本控制系統(tǒng)打Tag來結(jié)束, 那么或許應(yīng)該用另外的方式來做這些事情. 考慮下面的CruiseControl調(diào)用的Ant腳本例子:

          <project>
              <target name="dist" description="build everything">
              </target>
              <target name="clean" description="delete all build artifacts">
              </target>
              <target name="test" description="run unit tests">
              </target>
              <target name="publish" description="publish to repository">
              </target>

              <target name="cruise" depends="clean,dist,test,publish"/>      
          </project>


          構(gòu)建的最后一步是通過 "publish" target 發(fā)布通過了單元測試的工作產(chǎn)物到某個倉庫或類似的地方. 這對于CruiseControl來說不錯, 很好, 但是, "發(fā)布"的概念并不真正適合在開發(fā)者的構(gòu)建過程中使用.  如果我們能夠斷開"發(fā)布"和構(gòu)建過程的其它部分之間的聯(lián)系, 開發(fā)者就能夠和CruiseControl使用一模 一樣的構(gòu)建過程. 要想這樣做, 只需要讓CruiseControl來調(diào)用你開發(fā)過程中使用的構(gòu)建腳本, 而把"publish"作為一個獨(dú)立的Ant target:

          <project>
              <target name="dist" description="build everything">
              </target>
              <target name="clean" description="delete all build artifacts">
              </target>
              <target name="test" description="run unit tests">
              </target>

              <target name="dev" depends="clean,dist,test"/>
                 
              <target name="publish" description="publish to repository" if="logfile">
              </target>

          </project>

          'publish' target 中的 'if' 屬性用來保證這個target只會被 publisher 或某個特定的人來運(yùn)行. 接下來, 只需改動一下CruiseControl的配置:

          <!-- some config removed from this example -->

                  <schedule interval="60">
                      <ant antWorkingDir="${checkout.dir}" buildfile="build.xml" target="dev"/>
                  </schedule>

                  <publishers>
                      <onsuccess>
                          <antpublisher antWorkingDir="${checkout.dir}" buildfile="build.xml" target="publish"/>
                      <onsuccess>
                  </publishers>



          OK, 這就做完了.  一旦你應(yīng)用了新的配置, CruiseControl就會運(yùn)行和開發(fā)者一模一樣的Ant構(gòu)建. 這意味著構(gòu)建失敗時并不是因為 "CruiseControl" 做了什么神秘的事.  這還有助于通過更快的報告成功或失敗來縮短構(gòu)建的反饋周期.  當(dāng)開發(fā)者在慶祝或郁悶于構(gòu)建的成功或失敗時, AntPublisher 在同一時間繼續(xù)做著把構(gòu)建產(chǎn)物發(fā)布到網(wǎng)絡(luò)上的工作.  我還用它來為codebase打tag, 如果構(gòu)建成功的話--這件事也是"持續(xù)集成"的一部分.

          Publishers 能夠被直接用在配置文件的<publishers>元素中, 這樣每次構(gòu)建結(jié)束后無論成功失敗都會運(yùn)行. 也可以包在<onsuccess>或<onfailure>中有條件的運(yùn)行.

          Publishers 有一個堂兄妹表姐弟叫 Bootstrappers, 我另外找時間說說它.


          -----------------------------
          我想這個實踐的好處就是

          1. 開發(fā)者每次在自己機(jī)器上構(gòu)建時不需要發(fā)布, 省時間
          2. CruiseControl使用跟開發(fā)者相同的構(gòu)建腳本, 減少了開發(fā)者構(gòu)建成功而CruiseControl構(gòu)建失敗的概率, 省調(diào)試時間
          3. CruiseControl運(yùn)行Publisher時開發(fā)者可以繼續(xù)工作了, 提高了并發(fā)性, 還是省時間


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 邯郸县| 吕梁市| 新沂市| 汉源县| 塔城市| 将乐县| 安康市| 清丰县| 舞阳县| 保靖县| 孝感市| 定安县| 石渠县| 大姚县| 和平县| 平邑县| 丰镇市| 宁武县| 齐齐哈尔市| 利川市| 泰兴市| 浪卡子县| 乌恰县| 南宁市| 新民市| 西乡县| 凤阳县| 尉犁县| 长春市| 海兴县| 宿迁市| 蓬莱市| 聂荣县| 龙海市| 平武县| 湾仔区| 阜平县| 扶余县| 龙游县| 尚志市| 山阴县|