Skip to content

Commit

Permalink
Build: do not send notifications on known failed builds
Browse files Browse the repository at this point in the history
We do not want to send notifications (email or webhook) for known exceptions:

- Duplicated build
- Project builds skipped

Closes #7177
  • Loading branch information
humitos committed Feb 14, 2022
1 parent b5908b0 commit eb5ea47
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions readthedocs/projects/tasks/builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ class UpdateDocsTask(SyncRepositoryMixin, Task):
YAMLParseError,
)

# Do not send notifications on failure builds for these exceptions.
exceptions_without_notifications = (
DuplicatedBuildError,
ProjectBuildsSkippedError,
)

acks_late = True
track_started = True

Expand Down Expand Up @@ -394,11 +400,12 @@ def on_failure(self, exc, task_id, args, kwargs, einfo):
)

# Send notifications for unhandled errors
self.send_notifications(
self.data.version.pk,
self.data.build['id'],
event=WebHookEvent.BUILD_FAILED,
)
if not isinstance(exc, self.exceptions_without_notifications):
self.send_notifications(
self.data.version.pk,
self.data.build['id'],
event=WebHookEvent.BUILD_FAILED,
)

# NOTE: why we wouldn't have `self.data.build_commit` here?
# This attribute is set when we get it after clonning the repository
Expand Down

0 comments on commit eb5ea47

Please sign in to comment.