`
bluestar
  • 浏览: 372367 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

CruiseControl定时触发构建

阅读更多

CruiseControl倾向于通过源码变化来自动触发构建,但仍提供了几种方式来定时触发构建,以达到nightly building的效果。

在开始配置之前,先说明一下config.xml文件中Project元素的相关属性。

  • Project 元素对应你的一个需要构建的项目。其中:
  •  
    • name为其指定名称。
  •  
    • buildafterfailed 表示本次构建失败,是否要求CruiseControl继续下一次构建。
    •  
      • 当设置为true时,表示如果本次构建失败,即使没有任何人检入代码,间隔时间一到,CruiseControl也构建它。
    •  
      • 当设置为false时,表求如果本次构建失败,如果没有任何人检入代码,CruiseControl就不会再次构建它。
    • requireModification表示是否需要源文件发生变化才进行构建。
    •  
      • 当设置为true时,CruiseControl会根据modificationset元素的设置对源文件进行检查。
    •  
      • 当设置为false时,CruiseControl仅根据Schedule元素的设置进行定时构建。
    •  
      • 其默认值是ture。
    • forceOnly表示是否只能手工构建。
    •  
      • 当设置为true时,用户只能通过手工启动该项目的构建。
      • 当设置为false时,表示即可以根据条件自动构建,用户也可以通过手工构建(前提dashboard-config.xml中的配置必须是true)。
      • 其默认值是true。


为了达到定时构建的目的,首先要将Config.xml文件中该项目Project元素的requireModification属性设置为false。

一、每小时触发一次
设置Schedule元素的interval属性值为3600,即表示每小时会计划构建一次,由于requireModification已经设置为false,所以无论如何,CruiseControl都会构建。例如:

CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !         < schedule interval ="3600" >
CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !             
< ant anthome ="apache-ant-1.7.0" buildfile ="projects/${project.name}/build.xml" />
CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !         
</ schedule >



二、每天触发一次
       主要使用Schedule元素中各种构建器(如ant,nant,rake等)的time属性。time属性的格式为hhmm,例如2300就表示晚上十一点。

CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !         < schedule >
CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !             
< ant anthome ="xxxxxx" buildfile ="projects/${project.name}/xxxxx.xml" time ="2300" />
CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !         
</ schedule >    

当然,也可以使用pause子元素来指定在某段时间内不构建,如白天上班时间不构建,其它时间每隔一小时构建一次可用如下配置表示:

CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !         < schedule interval ="3600" >
CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !             
< ant anthome ="apache-ant-1.7.0" buildfile ="projects/${project.name}/build.xml" />
CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !             
< pause starttime ="0800" endtime ="1800" />
CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !         
</ schedule >



三、每周触发一次
       主要使用Schedule元素中各种构建器(如ant,nant,rake等)的time及day属性。day属性值为英文星期几且大小写不敏感,如sunday。

CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !         < schedule >
CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !             
< ant anthome ="apache-ant-1.7.0" buildfile ="projects/${project.name}/build.xml"    day ="Sunday" />
CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !         
</ schedule >

如果想指定具体时间,可以同时使用time属性,例如星期日的晚上十一点可以表示如下:

CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !         < schedule >
CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !             
< ant anthome ="apache-ant-1.7.0" buildfile ="projects/${project.name}/build.xml" time ="2300" day ="Sunday" />
CruiseControl定时触发构建 -CruiseControl Advanced (1) - moon - Linux Linux Linux !         
</ schedule >


需要说明的是,如果项目的构建时间长于指定的时间间隔,则构建次数会少于理想次数。例如设置每小时构建一次,但是每次构建要花费一个半小时。
另外,day属性还不支持多天,即不支持day="Monday Wednesday Friday"这种设置方式。如果想达到每隔一天构建一次的话,只能使用Schedule的interval属性。

个人建议,CruiseControl最好将触发事件写在各种Builder之外,而当前情况是:如果该Builder不支持time和day属性(如exec),可能就无法象上面所说的那样配置了。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics