Skip to content

Commit d046f02

Browse files
committed
Account when buildid is not set
1 parent ea272af commit d046f02

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

master/custom/pr_reporter.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ class GitHubPullRequestReporter(reporters.GitHubStatusPush):
6363
@defer.inlineCallbacks
6464
def sendMessage(self, reports):
6565
build = reports[0]['builds'][0]
66-
log.msg("Considering reporting build :{}".format(build['buildid']), logLevel=logging.INFO)
67-
6866
props = Properties.fromDict(build["properties"])
6967
props.master = self.master
7068

@@ -81,8 +79,11 @@ def sendMessage(self, reports):
8179
else:
8280
return
8381

82+
buildid = build.get('buildid', "???")
83+
log.msg("Considering reporting build :{}".format(buildid), logLevel=logging.INFO)
84+
8485
if state != "failure":
85-
log.msg("Not reporting build {} as it is not a failure".format(build['buildid']), logLevel=logging.INFO)
86+
log.msg("Not reporting build {} as it is not a failure".format(buildid), logLevel=logging.INFO)
8687
return
8788

8889
yield getDetailsForBuild(self.master, build, want_logs=True, want_logs_content=True, want_steps=True)
@@ -94,28 +95,28 @@ def sendMessage(self, reports):
9495
sourcestamps = build["buildset"].get("sourcestamps")
9596

9697
if not (sourcestamps and sourcestamps[0]):
97-
log.msg("Build {} not reported as it doesn't have source stamps".format(build['buildid']), logLevel=logging.INFO)
98+
log.msg("Build {} not reported as it doesn't have source stamps".format(buildid), logLevel=logging.INFO)
9899
return
99100

100101
changes = yield self.master.data.get(("builds", build["buildid"], "changes"))
101102

102103
if len(changes) != 1:
103-
log.msg("Build {} not reported as it has more than one change".format(build['buildid']), logLevel=logging.INFO)
104+
log.msg("Build {} not reported as it has more than one change".format(buildid), logLevel=logging.INFO)
104105
return
105106

106107
change = changes[0]
107108
change_comments = change["comments"]
108109

109110
if not change_comments:
110-
log.msg("Build {} not reported as no change comments could be found".format(build['buildid']), logLevel=logging.INFO)
111+
log.msg("Build {} not reported as no change comments could be found".format(buildid), logLevel=logging.INFO)
111112
return
112113

113114
# GH-42, gh-42, or #42
114115
m = re.search(r"\((?:GH-|#)(\d+)\)", change_comments, flags=re.IGNORECASE)
115116

116117
if m is None:
117118
log.msg("Build {} not reported as the issue could not be identified from the title".format(
118-
build['buildid']), logLevel=logging.INFO)
119+
buildid), logLevel=logging.INFO)
119120
return
120121

121122
issue = m.groups()[-1]
@@ -136,7 +137,7 @@ def sendMessage(self, reports):
136137
)
137138
)
138139

139-
log.msg("Attempting to issue a PR comment for failed build for build {}".format(build['buildid']), logLevel=logging.INFO)
140+
log.msg("Attempting to issue a PR comment for failed build for build {}".format(buildid), logLevel=logging.INFO)
140141
try:
141142
repo_user = repoOwner
142143
repo_name = repoName

0 commit comments

Comments
 (0)