From d5491731f42410b5f365a7316404f751e6f14d4b Mon Sep 17 00:00:00 2001 From: Radek Golan Date: Wed, 24 Apr 2024 15:04:12 +0200 Subject: [PATCH] Make sure logfiles get posted after the status embed --- src/discord_notifier/__main__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/discord_notifier/__main__.py b/src/discord_notifier/__main__.py index be98723..ce33c2a 100644 --- a/src/discord_notifier/__main__.py +++ b/src/discord_notifier/__main__.py @@ -20,7 +20,7 @@ class APISession(Session): url = self.base_url + url return super().request(method, url, *args, **kwargs) - +logfile_webhook = None webhook = DiscordWebhook(environ["PLUGIN_WEBHOOK_URL"], rate_limit_retry=True) success = environ["CI_PIPELINE_STATUS"] != "failure" @@ -67,6 +67,7 @@ webhook.add_embed(DiscordEmbed( try: if not success: + logfile_webhook = DiscordWebhook(environ["PLUGIN_WEBHOOK_URL"], rate_limit_retry=True) with APISession(environ["PLUGIN_WOODPECKER_URL"].rstrip("/")) as client: client.headers.setdefault("Authorization", f"Bearer {environ["PLUGIN_WOODPECKER_TOKEN"]}") @@ -101,4 +102,8 @@ except KeyError: )) pprint(webhook.json) -webhook.execute() +webhook.execute() + +if logfile_webhook is not None: + pprint(logfile_webhook.json) + logfile_webhook.execute()