diff -rN -u old-upstream-buildbot-mirror/buildbot/status/mail.py new-upstream-buildbot-mirror/buildbot/status/mail.py
|
old
|
new
|
|
| 63 | 63 | addLogs=False, relayhost="localhost", |
| 64 | 64 | subject="buildbot %(result)s in %(projectName)s on %(builder)s", |
| 65 | 65 | lookup=None, extraRecipients=[], |
| 66 | | sendToInterestedUsers=True): |
| | 66 | sendToInterestedUsers=True, |
| | 67 | messageGenerator=None): |
| 67 | 68 | """ |
| 68 | 69 | @type fromaddr: string |
| 69 | 70 | @param fromaddr: the email address to be used in the 'From' header. |
| … |
… |
|
| 127 | 128 | example, lookup='twistedmatrix.com' will allow mail |
| 128 | 129 | to be sent to all developers whose SVN usernames |
| 129 | 130 | match their twistedmatrix.com account names. |
| | 131 | @type messageGenerator: callable |
| | 132 | @param messageGenerator: Normally the message sent with a MailNotifier |
| | 133 | is built with MailNotifier.buildMessageBody. |
| | 134 | You may optionally use an alternative function. |
| | 135 | The signature of it should be as follows: |
| | 136 | func(builderName, mailNotifierMode, |
| | 137 | results, IBuildStatus, IStatus) |
| | 138 | where results is one of (SUCCESS, WARNINGS, |
| | 139 | FAILURE, SKIPPED, EXCEPTION). It should return |
| | 140 | a string that will be used as the body of the |
| | 141 | message sent by MailNotifier. |
| 130 | 142 | """ |
| 131 | 143 | |
| 132 | 144 | base.StatusReceiverMultiService.__init__(self) |
| … |
… |
|
| 151 | 163 | self.lookup = lookup |
| 152 | 164 | self.watched = [] |
| 153 | 165 | self.status = None |
| | 166 | assert messageGenerator is None or callable(messageGenerator) |
| | 167 | self.messageGenerator = messageGenerator |
| 154 | 168 | |
| 155 | 169 | # you should either limit on builders or categories, not both |
| 156 | 170 | if self.builders != None and self.categories != None: |
| … |
… |
|
| 216 | 230 | # rearrange this. |
| 217 | 231 | return self.buildMessage(name, build, results) |
| 218 | 232 | |
| 219 | | def buildMessage(self, name, build, results): |
| | 233 | def buildMessageBody(self, name, mode, results, build, masterStatus): |
| 220 | 234 | projectName = self.status.getProjectName() |
| 221 | 235 | text = "" |
| 222 | | if self.mode == "all": |
| | 236 | if mode == "all": |
| 223 | 237 | text += "The Buildbot has finished a build" |
| 224 | | elif self.mode == "failing": |
| | 238 | elif mode == "failing": |
| 225 | 239 | text += "The Buildbot has detected a failed build" |
| 226 | 240 | elif self.mode == "passing": |
| 227 | 241 | text += "The Buildbot has detected a passing build" |
| 228 | 242 | else: |
| 229 | 243 | text += "The Buildbot has detected a new failure" |
| 230 | 244 | text += " of %s on %s.\n" % (name, projectName) |
| 231 | | buildurl = self.status.getURLForThing(build) |
| | 245 | buildurl = masterStatus.getURLForThing(build) |
| 232 | 246 | if buildurl: |
| 233 | 247 | text += "Full details are available at:\n %s\n" % buildurl |
| 234 | 248 | text += "\n" |
| 235 | 249 | |
| 236 | | url = self.status.getBuildbotURL() |
| | 250 | url = masterStatus.getBuildbotURL() |
| 237 | 251 | if url: |
| 238 | 252 | text += "Buildbot URL: %s\n\n" % urllib.quote(url, '/:') |
| 239 | 253 | |
| 240 | 254 | text += "Buildslave for this Build: %s\n\n" % build.getSlavename() |
| 241 | 255 | text += "Build Reason: %s\n" % build.getReason() |
| 242 | 256 | |
| 243 | | patch = None |
| 244 | 257 | ss = build.getSourceStamp() |
| 245 | 258 | if ss is None: |
| 246 | 259 | source = "unavailable" |
| … |
… |
|
| 254 | 267 | source += "HEAD" |
| 255 | 268 | if ss.patch is not None: |
| 256 | 269 | source += " (plus patch)" |
| 257 | | patch = ss.patch |
| 258 | 270 | text += "Build Source Stamp: %s\n" % source |
| 259 | 271 | |
| 260 | 272 | text += "Blamelist: %s\n" % ",".join(build.getResponsibleUsers()) |
| … |
… |
|
| 270 | 282 | |
| 271 | 283 | if results == SUCCESS: |
| 272 | 284 | text += "Build succeeded!\n" |
| 273 | | res = "success" |
| 274 | 285 | elif results == WARNINGS: |
| 275 | 286 | text += "Build Had Warnings%s\n" % t |
| 276 | | res = "warnings" |
| 277 | 287 | else: |
| 278 | 288 | text += "BUILD FAILED%s\n" % t |
| 279 | | res = "failure" |
| 280 | | |
| 281 | | if self.addLogs and build.getLogs(): |
| 282 | | text += "Logs are attached.\n" |
| 283 | 289 | |
| 284 | 290 | # TODO: it would be nice to provide a URL for the specific build |
| 285 | 291 | # here. That involves some coordination with html.Waterfall . |
| … |
… |
|
| 293 | 299 | text += " -The Buildbot\n" |
| 294 | 300 | text += "\n" |
| 295 | 301 | |
| | 302 | return text |
| | 303 | |
| | 304 | def buildMessage(self, name, build, results): |
| | 305 | projectName = self.status.getProjectName() |
| | 306 | |
| | 307 | text = "" |
| | 308 | if self.messageGenerator: |
| | 309 | text = self.messageGenerator(name, self.mode, results, build, |
| | 310 | self.status) |
| | 311 | else: |
| | 312 | text = self.buildMessageBody(name, self.mode, results, build, |
| | 313 | self.status) |
| | 314 | |
| | 315 | if self.addLogs and build.getLogs(): |
| | 316 | text += "P.S. Logs are attached" |
| | 317 | |
| | 318 | patch = None |
| | 319 | ss = build.getSourceStamp() |
| | 320 | if ss and ss.patch: |
| | 321 | patch = ss.patch |
| | 322 | |
| | 323 | res = "" |
| | 324 | if results == SUCCESS: |
| | 325 | res = "success" |
| | 326 | elif results == WARNINGS: |
| | 327 | res = "warnings" |
| | 328 | else: |
| | 329 | res = "failure" |
| | 330 | |
| 296 | 331 | haveAttachments = False |
| 297 | 332 | if patch or self.addLogs: |
| 298 | 333 | haveAttachments = True |