]> git.ipfire.org Git - pbs.git/commitdiff
jobs: Improve the fail email (and include some parts of the log)
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 19 Oct 2022 15:40:32 +0000 (15:40 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 19 Oct 2022 15:40:32 +0000 (15:40 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/jobs.py
src/templates/jobs/messages/failed.txt

index 33a8acfc532caef1b70ce99f49b340618f6cf270..7f795a110b0b6a7051f1f1cecb3aad5f20e77e88 100644 (file)
@@ -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)
index 42073dc4ef352934580e5f202e381cf71ac120de..ad6f45b726809da4fac0e0081fddf4ff7563954b 100644 (file)
@@ -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 %}