Simplify messages for gitlab CI pipeline failed/canceled

This commit is contained in:
Alexandre Aubin 2023-01-20 12:36:43 +01:00
parent 12b5331266
commit 8235ac30f4

View file

@ -478,6 +478,16 @@ async def github(request):
branches = ", ".join((x["name"] for x in request.json["branches"])) branches = ", ".join((x["name"] for x in request.json["branches"]))
if state not in ("success", "pending"): if state not in ("success", "pending"):
if description == "Pipeline failed on GitLab":
pipeline_id = target_url.split("/")[-1]
await notify(
f'[{repository}] :red_circle: Pipeline [{pipeline_id}]({target_url}) failed on branch {branches}'
)
elif description == "Pipeline canceled on GitLab":
await notify(
f'[{repository}] :heavy_multiplication_x: Pipeline [{pipeline_id}]({target_url}) canceled on branch {branches}'
)
else:
await notify( await notify(
f'[{repository}] {description} {target_url} on commit {url} "{commit_message}" by @{commit_author} on branch{"es" if len(branches) > 1 else ""} {branches}' f'[{repository}] {description} {target_url} on commit {url} "{commit_message}" by @{commit_author} on branch{"es" if len(branches) > 1 else ""} {branches}'
) )