From fa9b02ccd169ea790395e5fed8c6e28699d831b2 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Tue, 29 Oct 2024 17:58:56 +0000 Subject: [PATCH] Account when buildid is not set (#550) --- master/custom/pr_reporter.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/master/custom/pr_reporter.py b/master/custom/pr_reporter.py index 953d6d43..ff01422f 100644 --- a/master/custom/pr_reporter.py +++ b/master/custom/pr_reporter.py @@ -63,8 +63,6 @@ class GitHubPullRequestReporter(reporters.GitHubStatusPush): @defer.inlineCallbacks def sendMessage(self, reports): build = reports[0]['builds'][0] - log.msg("Considering reporting build :{}".format(build['buildid']), logLevel=logging.INFO) - props = Properties.fromDict(build["properties"]) props.master = self.master @@ -81,8 +79,11 @@ def sendMessage(self, reports): else: return + buildid = build.get('buildid', "???") + log.msg("Considering reporting build :{}".format(buildid), logLevel=logging.INFO) + if state != "failure": - log.msg("Not reporting build {} as it is not a failure".format(build['buildid']), logLevel=logging.INFO) + log.msg("Not reporting build {} as it is not a failure".format(buildid), logLevel=logging.INFO) return yield getDetailsForBuild(self.master, build, want_logs=True, want_logs_content=True, want_steps=True) @@ -94,20 +95,20 @@ def sendMessage(self, reports): sourcestamps = build["buildset"].get("sourcestamps") if not (sourcestamps and sourcestamps[0]): - log.msg("Build {} not reported as it doesn't have source stamps".format(build['buildid']), logLevel=logging.INFO) + log.msg("Build {} not reported as it doesn't have source stamps".format(buildid), logLevel=logging.INFO) return changes = yield self.master.data.get(("builds", build["buildid"], "changes")) if len(changes) != 1: - log.msg("Build {} not reported as it has more than one change".format(build['buildid']), logLevel=logging.INFO) + log.msg("Build {} not reported as it has more than one change".format(buildid), logLevel=logging.INFO) return change = changes[0] change_comments = change["comments"] if not change_comments: - log.msg("Build {} not reported as no change comments could be found".format(build['buildid']), logLevel=logging.INFO) + log.msg("Build {} not reported as no change comments could be found".format(buildid), logLevel=logging.INFO) return # GH-42, gh-42, or #42 @@ -115,7 +116,7 @@ def sendMessage(self, reports): if m is None: log.msg("Build {} not reported as the issue could not be identified from the title".format( - build['buildid']), logLevel=logging.INFO) +buildid), logLevel=logging.INFO) return issue = m.groups()[-1] @@ -136,7 +137,7 @@ def sendMessage(self, reports): ) ) - log.msg("Attempting to issue a PR comment for failed build for build {}".format(build['buildid']), logLevel=logging.INFO) + log.msg("Attempting to issue a PR comment for failed build for build {}".format(buildid), logLevel=logging.INFO) try: repo_user = repoOwner repo_name = repoName