Ticket #87: custombuildproperties.diff
| File custombuildproperties.diff, 9.1 kB (added by rochg, 1 year ago) |
|---|
-
buildbot/status/html.py
old new 538 538 "<input type='text' name='branch' />") 539 539 + make_row("Revision to build:", 540 540 "<input type='text' name='revision' />") 541 + self.make_user_defined_rows() 542 541 543 + """ 542 544 <input type='submit' value='Force Build' /> 543 545 </form> … … 560 562 561 563 return data 562 564 565 # Providing the users custom properties are set in the master.cfg file 566 # this method will generate custom widgets (text fields, radio buttons and 567 # check boxes) for the slave build page. The method returns a html string 568 # representing the widgets. This string is added to the body of the slave 569 # build page. 570 def make_user_defined_rows(self): 571 userDefRows = name = type = label = value = "" 572 customBuildProperties = self.status.getCustomBuildProperties() 573 for properties in customBuildProperties: 574 name = properties['propertyName'] 575 type = properties['propertyType'] 576 label = properties['propertyLabel'] 577 if type == 'radio': 578 value = properties['groupValue'] 579 field = "<input type=" + "\'" + type + "\'" + "name=" + "\'" + \ 580 name + "\'" + "value=" + "\'" + value + "\'" + " />" 581 else: 582 field = "<input type=" + "\'" + type + "\'" + \ 583 "name=" + "\'" + name + "\'" + " />" 584 585 userDefRows += make_row(label, field) 586 name = type = label = value = "" 587 588 return userDefRows 589 563 590 def force(self, request): 564 591 name = request.args.get("username", ["<unknown>"])[0] 565 592 reason = request.args.get("comments", ["<no reason specified>"])[0] 566 593 branch = request.args.get("branch", [""])[0] 567 594 revision = request.args.get("revision", [""])[0] 568 595 596 # Custom properties. 597 custom_props = {} 598 forceBuildProperties = self.status.getCustomBuildProperties() 599 for dict in forceBuildProperties: 600 for key, value in dict.iteritems(): 601 if key == 'propertyName': 602 custom_props[value] = request.args.get(value, [""])[0] 603 569 604 r = "The web-page 'force build' button was pressed by '%s': %s\n" \ 570 605 % (name, reason) 571 606 log.msg("web forcebuild of builder '%s', branch='%s', revision='%s'" … … 593 628 # button, use their name instead of None, so they'll be informed of 594 629 # the results. 595 630 s = SourceStamp(branch=branch, revision=revision) 596 req = BuildRequest(r, s, self.builder.getName())631 req = BuildRequest(r, s, custom_props, self.builder.getName()) 597 632 try: 598 633 self.control.requestBuildSoon(req) 599 634 except interfaces.NoSlaveError: -
buildbot/status/builder.py
old new 1777 1777 return self.botmaster.parent.projectURL 1778 1778 def getBuildbotURL(self): 1779 1779 return self.botmaster.parent.buildbotURL 1780 def getCustomBuildProperties(self): 1781 return self.botmaster.parent.customBuildProperties 1780 1782 1781 1783 def getURLForThing(self, thing): 1782 1784 prefix = self.getBuildbotURL() -
buildbot/process/base.py
old new 39 39 provide this, but for forced builds the user requesting the 40 40 build will provide a string. 41 41 42 @type custom_props: dictionary. 43 @ivar custom_props: custom user properties. 44 42 45 @ivar status: the IBuildStatus object which tracks our status 43 46 44 47 @ivar submittedAt: a timestamp (seconds since epoch) when this request … … 49 52 source = None 50 53 builder = None 51 54 startCount = 0 # how many times we have tried to start this build 55 custom_props = {} 52 56 53 57 if implements: 54 58 implements(interfaces.IBuildRequestControl) 55 59 else: 56 60 __implements__ = interfaces.IBuildRequestControl, 57 61 58 def __init__(self, reason, source, builderName=None):62 def __init__(self, reason, source, custom_props, builderName=None): 59 63 # TODO: remove the =None on builderName, it is there so I don't have 60 64 # to change a lot of tests that create BuildRequest objects 61 65 assert interfaces.ISourceStamp(source, None) 62 66 self.reason = reason 63 67 self.source = source 68 self.custom_props = custom_props 64 69 self.start_watchers = [] 65 70 self.finish_watchers = [] 66 71 self.status = BuildRequestStatus(source, builderName) … … 87 92 self.finish_watchers.append(d) 88 93 return d 89 94 95 def customProps(self): 96 return self.custom_props; 97 90 98 # these are called by the Builder 91 99 92 100 def requestSubmitted(self, builder): … … 175 183 self.source = requests[0].mergeWith(requests[1:]) 176 184 self.reason = requests[0].mergeReasons(requests[1:]) 177 185 186 # Set custom properties. 187 self.custom_properties = requests[0].customProps() 188 178 189 #self.abandoned = False 179 190 180 191 self.progress = None … … 269 280 self.setProperty("buildnumber", self.build_status.number) 270 281 self.setProperty("branch", self.source.branch) 271 282 self.setProperty("revision", self.source.revision) 283 cp = self.custom_properties 284 for key,userProp in cp.iteritems(): 285 self.setProperty(key,userProp) 272 286 273 287 def setupSlaveBuilder(self, slavebuilder): 274 288 self.slavebuilder = slavebuilder -
buildbot/master.py
old new 543 543 projectURL = None 544 544 buildbotURL = None 545 545 change_svc = None 546 customBuildProperties = None 546 547 547 548 def __init__(self, basedir, configFileName="master.cfg"): 548 549 service.MultiService.__init__(self) … … 694 695 695 696 known_keys = "bots sources schedulers builders slavePortnum " + \ 696 697 "debugPassword manhole " + \ 697 "status projectName projectURL buildbotURL" 698 "status projectName projectURL buildbotURL " + \ 699 "customBuildProperties" 698 700 known_keys = known_keys.split() 699 701 for k in config.keys(): 700 702 if k not in known_keys: … … 715 717 projectName = config.get('projectName') 716 718 projectURL = config.get('projectURL') 717 719 buildbotURL = config.get('buildbotURL') 720 customBuildProperties = config.get('customBuildProperties') 718 721 719 722 except KeyError, e: 720 723 log.msg("config dictionary is missing a required parameter") … … 818 821 self.projectName = projectName 819 822 self.projectURL = projectURL 820 823 self.buildbotURL = buildbotURL 824 self.customBuildProperties = customBuildProperties 821 825 822 826 # self.bots: Disconnect any that were attached and removed from the 823 827 # list. Update self.checker with the new list of passwords, -
buildbot/scripts/sample.cfg
old new 173 173 # without some help. 174 174 175 175 c['buildbotURL'] = "http://localhost:8010/" 176 177 ###### CUSTOM BUILD PROPERTIES FOR THE SLAVE BUILD PAGE. 178 179 """ 180 textField = {'propertyName' : 'text_field', 181 'propertyType' : 'text', 182 'propertyLabel': 'Text Label', 183 } 184 185 checkBox = {'propertyName' : 'check_box', 186 'propertyType' : 'checkbox', 187 'propertyLabel': 'Check Box', 188 } 189 190 radio1 = {'propertyName' : 'radio_group', 191 'propertyType' : 'radio', 192 'propertyLabel': 'Male', 193 'groupValue' : 'm', 194 } 195 196 radio2 = {'propertyName' : 'radio_group', 197 'propertyType' : 'radio', 198 'propertyLabel': 'Female', 199 'groupValue' : 'f', 200 } 201 202 c['customBuildProperties'] = [textField, checkBox, radio1, radio2] 203 """
![[Buildbot Logo]](/trac/chrome/site/header-text-transparent.png)