1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import calendar
17 from zope.interface import implements
18 from twisted.python import log
19 from twisted.internet import defer
20 from buildbot import interfaces, sourcestamp
21 from buildbot.process import properties
22 from buildbot.status.results import FAILURE
23 from buildbot.db import buildrequests
26 """
27
28 A rolled-up encapsulation of all of the data relevant to a build request.
29
30 This class is used by the C{nextBuild} and C{mergeRequests} configuration
31 parameters, as well as in starting a build. Construction of a BuildRequest
32 object is a heavyweight process involving a lot of database queries, so
33 it should be avoided where possible. See bug #1894.
34
35 Build requests have a SourceStamp which specifies what sources to build.
36 This may specify a specific revision of the source tree (so source.branch,
37 source.revision, and source.patch are used). The .patch attribute is either
38 None or a tuple of (patchlevel, diff), consisting of a number to use in
39 'patch -pN', and a unified-format context diff.
40
41 Alternatively, the SourceStamp may specify a set of Changes to be built,
42 contained in source.changes. In this case, the requeset may be mergeable
43 with other BuildRequests on the same branch.
44
45 @type source: L{buildbot.sourcestamp.SourceStamp}
46 @ivar source: the source stamp that this BuildRequest use
47
48 @type reason: string
49 @ivar reason: the reason this Build is being requested. Schedulers provide
50 this, but for forced builds the user requesting the build will provide a
51 string. It comes from the buildsets table.
52
53 @type properties: L{properties.Properties}
54 @ivar properties: properties that should be applied to this build, taken
55 from the buildset containing this build request
56
57 @ivar submittedAt: a timestamp (seconds since epoch) when this request was
58 submitted to the Builder. This is used by the CVS step to compute a
59 checkout timestamp, as well as by the master to prioritize build requests
60 from oldest to newest.
61
62 @ivar buildername: name of the requested builder
63
64 @ivar priority: request priority
65
66 @ivar id: build request ID
67
68 @ivar bsid: ID of the parent buildset
69 """
70
71 source = None
72 submittedAt = None
73
74 @classmethod
76 """
77 Construct a new L{BuildRequest} from a dictionary as returned by
78 L{BuildRequestsConnectorComponent.getBuildRequest}.
79
80 This method uses a cache, which may result in return of stale objects;
81 for the most up-to-date information, use the database connector
82 methods.
83
84 @param master: current build master
85 @param brdict: build request dictionary
86
87 @returns: L{BuildRequest}, via Deferred
88 """
89 cache = master.caches.get_cache("BuildRequests", cls._make_br)
90 return cache.get(brdict['brid'], brdict=brdict, master=master)
91
92 @classmethod
93 @defer.deferredGenerator
94 - def _make_br(cls, brid, brdict, master):
137
140
143
145 """Return a reason for the merged build request."""
146 reasons = []
147 for req in [self] + others:
148 if req.reason and req.reason not in reasons:
149 reasons.append(req.reason)
150 return ", ".join(reasons)
151
154
155 @defer.deferredGenerator
182
184 implements(interfaces.IBuildRequestControl)
185
187 self.original_builder = builder
188 self.original_request = request
189 self.brid = request.id
190
192 raise NotImplementedError
193
195 raise NotImplementedError
196
200