Trees | Indices | Help |
|
---|
|
1 from buildbot.process.buildstep import LoggingBuildStep, SUCCESS, FAILURE, EXCEPTION 2 from buildbot.process.properties import Properties 3 from buildbot.schedulers.triggerable import Triggerable 4 from twisted.python import log 5 from twisted.internet import defer 68 """I trigger a scheduler.Triggerable, to use one or more Builders as if 9 they were a single buildstep (like a subroutine call). 10 """ 11 name = "trigger" 12 13 flunkOnFailure = True 14133 134 d.addCallbacks(cb, eb) 13515 - def __init__(self, schedulerNames=[], updateSourceStamp=True, 16 waitForFinish=False, set_properties={}, copy_properties=[], **kwargs):17 """ 18 Trigger the given schedulers when this step is executed. 19 20 @param schedulerNames: A list of scheduler names that should be 21 triggered. Schedulers can be specified using 22 WithProperties, if desired. 23 24 @param updateSourceStamp: If True (the default), I will try to give 25 the schedulers an absolute SourceStamp for 26 their builds, so that a HEAD build will use 27 the same revision even if more changes have 28 occurred since my build's update step was 29 run. If False, I will use the original 30 SourceStamp unmodified. 31 32 @param waitForFinish: If False (the default), this step will finish 33 as soon as I've started the triggered 34 schedulers. If True, I will wait until all of 35 the triggered schedulers have finished their 36 builds. 37 38 @param set_properties: A dictionary of properties to set for any 39 builds resulting from this trigger. These 40 properties will override properties set in the 41 Triggered scheduler's constructor. 42 43 @param copy_properties: a list of property names to copy verbatim 44 into any builds resulting from this trigger. 45 46 """ 47 assert schedulerNames, "You must specify a scheduler to trigger" 48 self.schedulerNames = schedulerNames 49 self.updateSourceStamp = updateSourceStamp 50 self.waitForFinish = waitForFinish 51 self.set_properties = set_properties 52 self.copy_properties = copy_properties 53 self.running = False 54 LoggingBuildStep.__init__(self, **kwargs) 55 self.addFactoryArguments(schedulerNames=schedulerNames, 56 updateSourceStamp=updateSourceStamp, 57 waitForFinish=waitForFinish, 58 set_properties=set_properties, 59 copy_properties=copy_properties)6062 # TODO: this doesn't actually do anything. 63 if self.running: 64 self.step_status.setText(["interrupted"])6567 properties = self.build.getProperties() 68 69 # make a new properties object from a dict rendered by the old 70 # properties object 71 props_to_set = Properties() 72 props_to_set.update(properties.render(self.set_properties), "Trigger") 73 for p in self.copy_properties: 74 if p not in properties: 75 raise RuntimeError("copy_property '%s' is not set in the triggering build" % p) 76 props_to_set.setProperty(p, properties[p], 77 "%s (in triggering build)" % properties.getPropertySource(p)) 78 79 self.running = True 80 ss = self.build.getSourceStamp() 81 if self.updateSourceStamp: 82 got = properties.getProperty('got_revision') 83 if got: 84 ss = ss.getAbsoluteSourceStamp(got) 85 86 # (is there an easier way to find the BuildMaster?) 87 all_schedulers = self.build.builder.botmaster.parent.allSchedulers() 88 all_schedulers = dict([(sch.name, sch) for sch in all_schedulers]) 89 unknown_schedulers = [] 90 triggered_schedulers = [] 91 92 # TODO: don't fire any schedulers if we discover an unknown one 93 for scheduler in self.schedulerNames: 94 scheduler = properties.render(scheduler) 95 if all_schedulers.has_key(scheduler): 96 sch = all_schedulers[scheduler] 97 if isinstance(sch, Triggerable): 98 triggered_schedulers.append(scheduler) 99 else: 100 unknown_schedulers.append(scheduler) 101 else: 102 unknown_schedulers.append(scheduler) 103 104 if unknown_schedulers: 105 self.step_status.setText(['no scheduler:'] + unknown_schedulers) 106 return self.finished(FAILURE) 107 108 dl = [] 109 for scheduler in triggered_schedulers: 110 sch = all_schedulers[scheduler] 111 dl.append(sch.trigger(ss, set_props=props_to_set)) 112 self.step_status.setText(['triggered'] + triggered_schedulers) 113 114 if self.waitForFinish: 115 d = defer.DeferredList(dl, consumeErrors=1) 116 else: 117 d = defer.succeed([]) 118 119 def cb(rclist): 120 rc = SUCCESS # (this rc is not the same variable as that above) 121 for was_cb, results in rclist: 122 # TODO: make this algo more configurable 123 if not was_cb: 124 rc = EXCEPTION 125 log.err(results) 126 break 127 if results == FAILURE: 128 rc = FAILURE 129 return self.finished(rc)130 131 def eb(why): 132 return self.finished(FAILURE)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Oct 29 10:00:44 2010 | http://epydoc.sourceforge.net |