def __init__(self, scheduler, username): self.scheduler = scheduler self.username = username self.jiraClient = None if self.scheduler.auto: self.jiraClient = JiraClient('mxjira')
class Try_Userpass_Perspective(pbutil.NewCredPerspective): def __init__(self, scheduler, username): self.scheduler = scheduler self.username = username self.jiraClient = None if self.scheduler.auto: self.jiraClient = JiraClient('mxjira') @defer.inlineCallbacks def perspective_try(self, branch, revision, patch, repository, taskId, project, builderNames, who="", comment="", properties={}): db = self.scheduler.master.db log.msg("user %s requesting build on builders %s" % (self.username, builderNames)) # build the intersection of the request and our configured list builderNames = self.scheduler.filterBuilderList(builderNames) if not builderNames: log.msg("incoming Try job from user %s did not specify a valid job id" % self.username) return # Mx specific if self.scheduler.auto: if not taskId: log.msg("incoming Try auto job from user %s did not specify a task id" % self.username) return issue = self.jiraClient.getIssue(taskId) if not issue: log.msg("incoming Try auto job from user %s did not specify a valid task id" % self.username) return properties["tpks"]=issue["tpks"] properties["taskId"]=taskId log.msg("incoming Try auto job from user %s properties %s" % (self.username, properties["tpks"]) ) reason = "'try' job" if who: reason += " by user %s" % who if comment: reason += " (%s)" % comment sourcestampsetid = yield db.sourcestampsets.addSourceStampSet() yield db.sourcestamps.addSourceStamp( branch=branch, revision=revision, repository=repository, project=project, patch_level=patch[0], patch_body=patch[1], patch_subdir='', patch_author=who or '', patch_comment=comment or '', sourcestampsetid=sourcestampsetid) # note: no way to specify patch subdir - #1769 requested_props = Properties() requested_props.update(properties, "try build") (bsid, brids) = yield self.scheduler.addBuildsetForSourceStamp( setid=sourcestampsetid, reason=reason, properties=requested_props, builderNames=builderNames) # return a remotely-usable BuildSetStatus object bsdict = yield db.buildsets.getBuildset(bsid) bss = BuildSetStatus(bsdict, self.scheduler.master.status) from buildbot.status.client import makeRemote defer.returnValue(makeRemote(bss)) def perspective_getAvailableBuilderNames(self): # Return a list of builder names that are configured # for the try service # This is mostly intended for integrating try services # into other applications return self.scheduler.listBuilderNames()