Package buildbot :: Module buildrequest
[frames] | no frames]

Source Code for Module buildbot.buildrequest

  1  # This file is part of Buildbot.  Buildbot is free software: you can 
  2  # redistribute it and/or modify it under the terms of the GNU General Public 
  3  # License as published by the Free Software Foundation, version 2. 
  4  # 
  5  # This program is distributed in the hope that it will be useful, but WITHOUT 
  6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
  7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
  8  # details. 
  9  # 
 10  # You should have received a copy of the GNU General Public License along with 
 11  # this program; if not, write to the Free Software Foundation, Inc., 51 
 12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
 13  # 
 14  # Copyright Buildbot Team Members 
 15   
 16  from buildbot import interfaces 
 17  from buildbot.process.properties import Properties 
 18   
19 -class BuildRequest:
20 """I represent a request to a specific Builder to run a single build. 21 22 I am generated by db.getBuildRequestWithNumber, and am used to tell the 23 Build about what it ought to be building. I am also used by the Builder 24 to let hook functions decide which requests should be handled first. 25 26 I have a SourceStamp which specifies what sources I will build. This may 27 specify a specific revision of the source tree (so source.branch, 28 source.revision, and source.patch are used). The .patch attribute is 29 either None or a tuple of (patchlevel, diff), consisting of a number to 30 use in 'patch -pN', and a unified-format context diff. 31 32 Alternatively, the SourceStamp may specify a set of Changes to be built, 33 contained in source.changes. In this case, I may be mergeable with other 34 BuildRequests on the same branch. 35 36 @type source: a L{buildbot.sourcestamp.SourceStamp} instance. 37 @ivar source: the source code that this BuildRequest use 38 39 @type reason: string 40 @ivar reason: the reason this Build is being requested. Schedulers 41 provide this, but for forced builds the user requesting the 42 build will provide a string. 43 44 @type properties: Properties object 45 @ivar properties: properties that should be applied to this build 46 'owner' property is used by Build objects to collect 47 the list returned by getInterestedUsers 48 49 @ivar status: the IBuildStatus object which tracks our status 50 51 @ivar submittedAt: a timestamp (seconds since epoch) when this request 52 was submitted to the Builder. This is used by the CVS 53 step to compute a checkout timestamp, as well as the 54 master to prioritize build requests from oldest to 55 newest. 56 """ 57 58 source = None 59 builder = None # XXXREMOVE 60 startCount = 0 # how many times we have tried to start this build # XXXREMOVE 61 submittedAt = None 62
63 - def __init__(self, reason, source, builderName, properties=None):
64 assert interfaces.ISourceStamp(source, None) 65 self.reason = reason 66 self.source = source 67 self.builderName = builderName 68 69 self.properties = Properties() 70 if properties: 71 self.properties.updateFromProperties(properties)
72
73 - def canBeMergedWith(self, other):
74 return self.source.canBeMergedWith(other.source)
75
76 - def mergeWith(self, others):
77 return self.source.mergeWith([o.source for o in others])
78
79 - def mergeReasons(self, others):
80 """Return a reason for the merged build request.""" 81 reasons = [] 82 for req in [self] + others: 83 if req.reason and req.reason not in reasons: 84 reasons.append(req.reason) 85 return ", ".join(reasons)
86 87 # IBuildRequestControl 88
89 - def cancel(self): # XXXREMOVE
90 """Cancel this request. This can only be successful if the Build has 91 not yet been started. 92 93 @return: a boolean indicating if the cancel was successful.""" 94 if self.builder: 95 return self.builder.cancelBuildRequest(self) 96 return False
97
98 - def getSubmitTime(self):
99 return self.submittedAt
100