1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
'''
Created on June 28, 2013
__author__ = "Elizabeth 'pidge' Flanagan"
__copyright__ = "Copyright 2012-2013, Intel Corp."
__credits__ = ["Elizabeth Flanagan"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = "Elizabeth Flanagan"
__email__ = "pidge@toganlabs.com"
'''
from buildbot.status.mail import MailNotifier
from buildbot.status.mail import *
from buildbot import interfaces, util, config
from buildbot.process.users import users
from buildbot.status import base
from buildbot.status.results import FAILURE, SUCCESS, WARNINGS, EXCEPTION, Results
from twisted.python import log
class YoctoMailNotifier(MailNotifier):
def __init__(self, fromaddr, mode=("failing"),
categories=None, branches=None, yoctorepos=None, builders=None, addLogs=False,
relayhost="localhost", buildSetSummary=False,
subject="buildbot %(result)s in %(title)s on %(builder)s",
lookup=None, extraRecipients=[],
sendToInterestedUsers=True, customMesg=None,
messageFormatter=defaultMessage, extraHeaders=None,
addPatch=True, useTls=False,
smtpUser=None, smtpPassword=None, smtpPort=25):
self.fromaddr = fromaddr
self.mode=mode
self.categories = categories
self.branches = branches
self.yoctorepos = yoctorepos
self.builders = builders
self.addLogs = addLogs
self.relayhost = relayhost
self.buildSetSummary = buildSetSummary
self.subject = subject
self.lookup = lookup
self.extraRecipients = extraRecipients
self.sendToInterestedUsers = sendToInterestedUsers
self.customMesg = customMesg
self.messageFormatter = messageFormatter
self.extraHeaders = extraHeaders
self.addPatch = addPatch
self.useTls = useTls
self.smtpUser = smtpUser
self.smtpPassword = smtpPassword
self.smtpPort = smtpPort
MailNotifier.__init__(self, fromaddr, mode=self.mode,
categories = self.categories, builders = self.builders,
addLogs = self.addLogs, relayhost = self.relayhost,
buildSetSummary = self.buildSetSummary,
subject = self.subject,
lookup = self.lookup,
extraRecipients = self.extraRecipients,
sendToInterestedUsers = self.sendToInterestedUsers,
customMesg = self.customMesg,
messageFormatter = self.messageFormatter,
extraHeaders = self.extraHeaders, addPatch = self.addPatch,
useTls = self.useTls, smtpUser = self.smtpUser,
smtpPassword = self.smtpPassword, smtpPort = self.smtpPort)
def isMailNeeded(self, build, results):
# here is where we actually do something.
builder = build.getBuilder()
repo=build.getProperty("repository")
branch=build.getProperty("branch")
log.msg(repo)
log.msg(branch)
buildme = False
if self.builders is not None and builder.name not in self.builders:
return False # ignore this build
if self.categories is not None and \
builder.category not in self.categories:
return False # ignore this build
if self.yoctorepos is not None and repo in self.yoctorepos:
if self.branches is not None:
if branch in self.branches:
buildme = True
else:
return False # ignore this build
elif self.yoctorepos is None:
if self.branches is not None and branch in self.branches:
buildme = True
elif self.branches is not None and branch not in self.branches:
return False # ignore this build
else:
buildme = True
if buildme is True:
prev = build.getPreviousBuild()
if "change" in self.mode:
if prev and prev.getResults() != results:
return True
if "failing" in self.mode and results == FAILURE:
return True
if "passing" in self.mode and results == SUCCESS:
return True
if "problem" in self.mode and results == FAILURE:
if prev and prev.getResults() != FAILURE:
return True
if "warnings" in self.mode and results == WARNINGS:
return True
if "exception" in self.mode and results == EXCEPTION:
return True
return False
|