-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
airbyte-ci: send publish failures to a dedicated slack channel (#42849)
- Loading branch information
1 parent
ba73d5c
commit e4833f6
Showing
14 changed files
with
64 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 16 additions & 7 deletions
23
airbyte-ci/connectors/pipelines/pipelines/helpers/slack.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# | ||
from __future__ import annotations | ||
|
||
import json | ||
import typing | ||
|
||
import requests | ||
from pipelines import main_logger | ||
|
||
if typing.TYPE_CHECKING: | ||
from typing import List | ||
|
||
def send_message_to_webhook(message: str, channel: str, webhook: str) -> requests.Response: | ||
payload = {"channel": f"#{channel}", "username": "Connectors CI/CD Bot", "text": message} | ||
response = requests.post(webhook, data={"payload": json.dumps(payload)}) | ||
|
||
# log if the request failed, but don't fail the pipeline | ||
if not response.ok: | ||
main_logger.error(f"Failed to send message to slack webhook: {response.text}") | ||
def send_message_to_webhook(message: str, channels: List[str], webhook: str) -> List[requests.Response]: | ||
responses = [] | ||
for channel in channels: | ||
channel = channel[1:] if channel.startswith("#") else channel | ||
payload = {"channel": f"#{channel}", "username": "Connectors CI/CD Bot", "text": message} | ||
response = requests.post(webhook, data={"payload": json.dumps(payload)}) | ||
|
||
return response | ||
# log if the request failed, but don't fail the pipeline | ||
if not response.ok: | ||
main_logger.error(f"Failed to send message to slack webhook: {response.text}") | ||
responses.append(response) | ||
|
||
return responses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters