From f81543e86bdac77a074bcec2d9bb47d53684cf63 Mon Sep 17 00:00:00 2001 From: ibrahimjaved12 <109785089+ibrahimjaved12@users.noreply.github.com> Date: Mon, 19 Aug 2024 19:56:15 +0500 Subject: [PATCH] Add SlackAlertStep in remove_unpublished_sites pipeline (#2271) * Add SlackAlertStep in remove_unpublished_sites pipeline * Add resources * Add Slack alert for Abort --- .../concourse/remove_unpublished_sites.py | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/content_sync/pipelines/definitions/concourse/remove_unpublished_sites.py b/content_sync/pipelines/definitions/concourse/remove_unpublished_sites.py index a1444b6dd..323236a07 100644 --- a/content_sync/pipelines/definitions/concourse/remove_unpublished_sites.py +++ b/content_sync/pipelines/definitions/concourse/remove_unpublished_sites.py @@ -13,6 +13,7 @@ TaskConfig, TaskStep, ) +from ol_concourse.lib.resource_types import slack_notification_resource from content_sync.constants import DEV_ENDPOINT_URL, VERSION_LIVE from content_sync.pipelines.definitions.concourse.common.identifiers import ( @@ -33,6 +34,7 @@ from content_sync.pipelines.definitions.concourse.common.steps import ( ClearCdnCacheStep, OcwStudioWebhookCurlStep, + SlackAlertStep, ) from content_sync.utils import ( get_cli_endpoint_url, @@ -87,6 +89,7 @@ def __init__(self, **kwargs): HttpResourceType(), S3IamResourceType(), ] + resources = [] unpublish_failed_webhook_across_step = OcwStudioWebhookCurlStep( site_name="((.:site.name))", data={"version": VERSION_LIVE, "status": "errored", "unpublished": True}, @@ -212,6 +215,22 @@ def __init__(self, **kwargs): ), ] job = Job(name=self._remove_unpublished_sites_job_identifier, serial=True) - + if not is_dev(): + resource_types.append(slack_notification_resource()) + resources.append(self._slack_resource) + job.on_failure = SlackAlertStep( + alert_type="failed", + text=""" + Failed to remove unpublished site. Check the pipeline logs for more details. + """, # noqa: E501 + ) + job.on_abort = SlackAlertStep( + alert_type="aborted", + text=""" + User aborted the unpublish operation for site. Check the pipeline logs for more details. + """, # noqa: E501 + ) job.plan = tasks - base.__init__(resource_types=resource_types, jobs=[job], **kwargs) + base.__init__( + resource_types=resource_types, resources=resources, jobs=[job], **kwargs + )