From: Michael Tremer Date: Wed, 19 Oct 2022 15:40:32 +0000 (+0000) Subject: jobs: Improve the fail email (and include some parts of the log) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=af2e99269e5f4de64ed4967c9e414d99cbccfce0;p=pbs.git jobs: Improve the fail email (and include some parts of the log) Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/jobs.py b/src/buildservice/jobs.py index 33a8acfc..7f795a11 100644 --- a/src/buildservice/jobs.py +++ b/src/buildservice/jobs.py @@ -289,7 +289,13 @@ class Job(base.DataObject): # Notify the owner if self.build.owner: - self.build.owner.send_email("jobs/messages/failed.txt", job=self) + # Tail the log + log = await self.tail_log(100) + + # Send an email + self.build.owner.send_email( + "jobs/messages/failed.txt", job=self, build=self.build, log=log, + ) # Propagate any changes to the build await self.build._job_finished(job=self) diff --git a/src/templates/jobs/messages/failed.txt b/src/templates/jobs/messages/failed.txt index 42073dc4..ad6f45b7 100644 --- a/src/templates/jobs/messages/failed.txt +++ b/src/templates/jobs/messages/failed.txt @@ -1,16 +1,22 @@ To: {{ recipient.email_to }} Subject: [{{ job.name }}] {{ _("Build Job Failed") }} -{{ _("The build job %s has failed") % job.name }}. -{{ _("This could have a couple of reasons and needs to be investigated by you.") }} +{{ _("Hello %s,") % recipient }} -{{ _("Here is more information about the incident:") }} +{{ _("This is an automated email to let you know that this build job has failed:") }} -* {{ _("Name") }}: {{ job.name }} -{% if job.builder %}* {{ _("Builder") }}: {{ job.builder }}{% end %} + /builds/{{ build.uuid }} -{{ _("Click on this link to get all details about the build:") }} - {{ baseurl }}/job/{{ job.uuid }} +{% if log %} +{{ _("Below, you will find an excerpt of the log, which might be helpful looking for the problem.") }} +{% end %} {{ _("Sincerely,") }} -{{ _("The Pakfire Build Service") }} + +{# Show the log if we have one #} +{% if log %} + ---- {{ _("The last line of the log", "The last %(n)s lines of the log", len(log)) % { "n" : len(log) } }} ---- + +{% for line in log %}{{ line }}{% end %} +{% end %}