Make sure logfiles get posted after the status embed

This commit is contained in:
Radek Golan 2024-04-24 15:04:12 +02:00
parent 653d66db40
commit d5491731f4

View File

@ -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()