From 935867aa7e2e61a2071b74f132049b3f70070756 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Tue, 26 May 2020 14:04:40 -0500 Subject: [PATCH] Make IRC messages more granular, and don't forget to return Ok. --- lugito/connectors/jenkins.py | 40 ++++++++++++++++++++++++++++++++++-- lugito/webhooks.py | 2 ++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/lugito/connectors/jenkins.py b/lugito/connectors/jenkins.py index b992af4..e156e05 100644 --- a/lugito/connectors/jenkins.py +++ b/lugito/connectors/jenkins.py @@ -123,14 +123,50 @@ class jenkins(object): if not proj: return status - # Return the status of the last completed build + # Get the status of the last completed build if there isone try: + # Get the data from Jenkins status = proj[1].get_last_completed_build().get_status() url = proj[1].get_last_completed_build().get_build_url() - return proj[0], status, url except jenkinsapi.custom_exceptions.NoBuildData: return None + # Get the status of - 1 + last_status = proj[1].get_build(proj[1].get_last_buildnumber() - 1) + last_status = last_status.get_status() + + # If it has been consistently stable, don't cause extra noise + if status == "SUCCESS" and last_status == status: + return None + + # Customize the message depending on the previous build status + if status == "SUCCESS": + if last_status == "FAILURE": + status = "just succeeded after failing" + elif last_status == "UNSTABLE": + status = "just became stable" + # Color it green + status = "\x033" + status + "\x03" + elif status == "FAILURE": + if last_status == "SUCCESS": + status = "just failed after succeeding" + elif last_status == "UNSTABLE": + status = "just failed after being unstable" + # Color it red + status = "\x034" + status + "\x03" + elif status == "UNSTABLE": + if last_status == "SUCCESS": + status = "just became unstable" + elif last_status == "FAILURE": + status = "just became unstable after failing" + # Color it yellow + status = "\x038" + status + "\x03" + elif status == "ABORTED": + # Color it gray + status = "\x0315" + status + "\x03" + + return proj[0], status, url + def listen(self): pass diff --git a/lugito/webhooks.py b/lugito/webhooks.py index f30e577..efe07e9 100644 --- a/lugito/webhooks.py +++ b/lugito/webhooks.py @@ -199,6 +199,8 @@ def jenkinsircnotify(): if status: irc_con.send("Lubuntu CI", proj, status, link) + return 'Ok' + def run(): irc_con.connect()