diff --git a/runbot/data/build_parse.xml b/runbot/data/build_parse.xml index 79903ae8..9514aa6c 100644 --- a/runbot/data/build_parse.xml +++ b/runbot/data/build_parse.xml @@ -6,7 +6,7 @@ ir.actions.server code - records._parse_logs() + action = records._parse_logs() @@ -16,7 +16,7 @@ ir.actions.server code - records._parse_logs() + action = records._parse_logs() diff --git a/runbot/models/build.py b/runbot/models/build.py index 59208f28..429367f6 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -1022,7 +1022,7 @@ class BuildResult(models.Model): # only parse logs from builds in error and not already scanned builds_to_scan = self.search([('id', 'in', self.ids), ('local_result', '=', 'ko'), ('build_error_ids', '=', False)]) ir_logs = self.env['ir.logging'].search([('level', '=', 'ERROR'), ('type', '=', 'server'), ('build_id', 'in', builds_to_scan.ids)]) - BuildError._parse_logs(ir_logs) + return BuildError._parse_logs(ir_logs) def is_file(self, file, mode='r'): file_path = self._path(file) diff --git a/runbot/models/build_error.py b/runbot/models/build_error.py index e0e492b6..62f652de 100644 --- a/runbot/models/build_error.py +++ b/runbot/models/build_error.py @@ -129,21 +129,36 @@ class BuildError(models.Model): fingerprint = self._digest(cleaning_regs.r_sub('%', log.message)) hash_dict[fingerprint].append(log) + build_errors = self.env['runbot.build.error'] # add build ids to already detected errors - for build_error in self.env['runbot.build.error'].search([('fingerprint', 'in', list(hash_dict.keys())), ('active', '=', True)]): + existing_errors = self.env['runbot.build.error'].search([('fingerprint', 'in', list(hash_dict.keys())), ('active', '=', True)]) + build_errors |= existing_errors + for build_error in existing_errors: for build in {rec.build_id for rec in hash_dict[build_error.fingerprint]}: build.build_error_ids += build_error del hash_dict[build_error.fingerprint] # create an error for the remaining entries for fingerprint, logs in hash_dict.items(): - build_error = self.env['runbot.build.error'].create({ + build_errors |= self.env['runbot.build.error'].create({ 'content': logs[0].message, 'module_name': logs[0].name, 'function': logs[0].func, 'build_ids': [(6, False, [r.build_id.id for r in logs])], }) + if build_errors: + window_action = { + "type": "ir.actions.act_window", + "res_model": "runbot.build.error", + "views": [[False, "tree"]], + "domain": [('id', 'in', build_errors.ids)] + } + if len(build_errors) == 1: + window_action["views"] = [[False, "form"]] + window_action["res_id"] = build_errors.id + return window_action + def link_errors(self): """ Link errors with the first one of the recordset choosing parent in error with responsible, random bug and finally fisrt seen diff --git a/runbot/models/event.py b/runbot/models/event.py index a737fa33..d4c97be1 100644 --- a/runbot/models/event.py +++ b/runbot/models/event.py @@ -179,7 +179,7 @@ class RunbotErrorLog(models.Model): def _parse_logs(self): BuildError = self.env['runbot.build.error'] - BuildError._parse_logs(self) + return BuildError._parse_logs(self) def init(self): """ Create an SQL view for ir.logging """