diff --git a/src/discord_notifier/__main__.py b/src/discord_notifier/__main__.py index aa62cee..779507f 100644 --- a/src/discord_notifier/__main__.py +++ b/src/discord_notifier/__main__.py @@ -68,15 +68,19 @@ try: if not success: with APISession(environ["PLUGIN_WOODPECKER_URL"].rstrip("/")) as client: client.headers.setdefault("Authorization", f"Bearer {environ["PLUGIN_WOODPECKER_TOKEN"]}") - pipeline_url = urlparse(environ["CI_PIPELINE_URL"]).path + "s" - pipeline_info = client.get(pipeline_url).json() + + pipeline_url = urlparse(environ["CI_PIPELINE_URL"]).path.lstrip("/").split("/") + repo_id = pipeline_url[1] + pipeline_number = pipeline_url[3] + + pipeline_info = client.get(f"/repos/{repo_id}/pipelines/{pipeline_number}").json() for workflow in pipeline_info["workflows"]: if workflow["name"] != environ["CI_WORKFLOW_NAME"]: continue for step in workflow["children"]: if step["state"] != "failure": continue - logdata = client.get(urljoin(pipeline_url, step["id"])) + logdata = client.get(f"/repos/{repo_id}/pipelines/{pipeline_number}/{step['id']}") webhook.add_file(logdata.content, f"{step['name']}.log") except KeyError: webhook.add_embed(DiscordEmbed(