buildbot的codebaseGenerator

buildbot的codebaseGenerator文档非常简单,简单到令人发指。

也没有一个例子,唉,辛苦了好几个小时才研究清楚怎么设置。

赶紧记录下吧,不然下次又要纠结。

 

应用场景:web status页面里面的 ForceScheduler使用codebases参数指定多个codebase,在页面Force启动时,可以动态对一个repository指定branch,URL等信息,
方便自定义。

 



首先,文档说了:
For any incoming change, the codebase is set to ''. This codebase value is sufficient if all changes come from the same repository (or clones). If changes come from different repositories, extra processing will be needed to determine the codebase for the incoming change. This codebase will then be a logical name for the combination of repository and or branch etc.
The codebaseGenerator accepts a change dictionary as produced by thebuildbot.db.changes.ChangesConnectorComponent, with a changeid equal to None.


配置主要涉及三个地方:
- 全局字典需要设置 'codebaseGenerator' 参数。
- ForceScheduler需要通过参数codebases指定相关的repository。
- source checkout step 需要通过codebase参数指定确定的repos。
关键配置代码如下:

REPOS1_URL = '[email protected]:repos1.git'



REPOS2_URL = '[email protected]:repos2.git'



all_repositories = {

REPOS1_URL : 'repos1',

REPOS2_URL : 'repos2',

}





def codebaseGenerator(chdict):

return constants.all_repositories[chdict['repository']]





c['codebaseGenerator'] = codebaseGenerator





all_code_bases = [ 

    CodebaseParameter(codebase = 'repos1'),

    CodebaseParameter(codebase = 'repos2'),

]



_schedulers.append(ForceScheduler(

                  name="manual_start_im_build",

                  builderNames=["builder"],

                  buttonName = "Do the magic",

                  codebases = all_code_bases,

                  properties = [ ],  

                  )) 

 

你可能感兴趣的:(generator)