diff --git a/messaging/copr_messaging/private/hierarchy.py b/messaging/copr_messaging/private/hierarchy.py index c846fa6ec..a333f1a6a 100644 --- a/messaging/copr_messaging/private/hierarchy.py +++ b/messaging/copr_messaging/private/hierarchy.py @@ -184,6 +184,7 @@ def usernames(self): class _BuildChrootMessage(_BuildMessage): + @property def chroot(self): """ diff --git a/messaging/copr_messaging/schema.py b/messaging/copr_messaging/schema.py index ab8b18023..ed77885bb 100644 --- a/messaging/copr_messaging/schema.py +++ b/messaging/copr_messaging/schema.py @@ -20,6 +20,8 @@ import copy +from fedora_messaging import message + from copr_common.enums import StatusEnum from .private.hierarchy import _BuildChrootMessage, _CoprMessage @@ -27,6 +29,15 @@ from .private import schema_stomp_old +_build_ended_template = """Package: {name}-{version}-{release} +Status: {status} +Built by: {owner_name} +ID: {id} +Started: {started} +Finished: {finished} + +""" + class BuildChrootEnded(_BuildChrootMessage): """ Representation of a message sent by Copr build system right after some Copr @@ -47,6 +58,25 @@ def summary(self): self.status, ) + def __str__(self): + _build_str = _build_template.format( + name=self.name, + version=self.version, + release=self.release, + status=self.new_state_name, + owner_name=self.owner, + id=self.build_id, + started=date_to_string(self.body["creation_time"]), + finished=date_to_string(self.body["completion_time"]) or "(still running)", + ) + if self.body["task"] is None: + _task_str = "Build imported into koji\n" + else: + _task_str = "Closed tasks:\n-------------\n" + _task_str += fill_task_template(self.body["task"], self.body["files_base_url"]) + + return _build_str + _task_str + @property def agent_name(self): """The username who caused the action that generated this message.""" @@ -100,6 +130,12 @@ class BuildChrootStartedV1DontUse(_PreFMBuildMessage, BuildChrootStarted): """ topic = 'copr.chroot.start' + # Set the chroot message severity to DEBUG, which will not generate a notification in FMN by + # default. Those are always paired with a build message, so it makes more sense to notify on + # that one. + # Ref: https://fedora-messaging.readthedocs.io/en/stable/user-guide/messages.html#useful-accessors + severity = message.DEBUG + class BuildChrootStartedV1Stomp(schema_stomp_old._OldStompChrootMessage, BuildChrootStarted):