Skip to content

Commit 2ecda6a

Browse files
committed
Fix email notifications on build failures
1 parent 141ebf0 commit 2ecda6a

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

readthedocs/projects/tasks.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ def run(self, pk, version_pk=None, build_pk=None, record=True, docker=False,
142142
epub=outcomes['epub'],
143143
)
144144

145+
if self.build_env.failed:
146+
self.send_notifications()
147+
145148
@staticmethod
146149
def get_project(project_pk):
147150
"""
@@ -424,6 +427,14 @@ def build_docs_class(self, builder_class):
424427
builder.move()
425428
return success
426429

430+
def send_notifications(self):
431+
"""Send notifications on build failure
432+
433+
Don't send failure notices on ``stable`` version builds.
434+
"""
435+
if self.version.slug != STABLE:
436+
send_notifications.delay(self.version.pk, build_pk=self.build['id'])
437+
427438

428439
update_docs = celery_app.tasks[UpdateDocsTask.name]
429440

@@ -543,8 +554,6 @@ def finish_build(version_pk, build_pk, hostname=None, html=False,
543554
update_static_metadata.delay(version.project.pk)
544555
fileify.delay(version.pk, commit=build.commit)
545556
update_search.delay(version.pk, commit=build.commit)
546-
if not html and version.slug != STABLE and build.exit_code != 423:
547-
send_notifications.delay(version.pk, build_pk=build.pk)
548557

549558

550559
@task(queue='web')

readthedocs/templates/projects/email/build_failed.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
{% endblock %}
1010

1111
{% block content %}
12+
{% if build.error %}
13+
<p>
14+
Error: {{ build.error }}
15+
</p>
16+
{% endif %}
17+
1218
<p>
13-
You can see what went wrong here:
19+
You can find out more about this failure here:
1420
</p>
1521

1622
<p>

readthedocs/templates/projects/email/build_failed.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{% extends "core/email/common.txt" %}
22
{% block salutation %}Build Failed for {{ project.name }} ({{ version.verbose_name }}){% endblock %}
33
{% block content %}
4-
5-
6-
7-
8-
You can see what went wrong here:
4+
{% if build.error %}
5+
Error:
6+
{{ build.error }}
7+
{% endif %}
8+
You can find out more about this failure here:
99
{{ build_url }}
1010

1111
If you have questions, a good place to start is the FAQ:

0 commit comments

Comments
 (0)