From 4f57d35613540833de3b6fb9fc84010f1d8ec42f Mon Sep 17 00:00:00 2001 From: Steve Halford Date: Thu, 15 Aug 2013 13:25:31 +0100 Subject: [PATCH] Use build number to construct call back URL The lastFailedBuild url doesn't work on our installation of jenkins, this uses the build number from the data received to construct the url. --- retaliation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/retaliation.py b/retaliation.py index 763c829..293d3a9 100755 --- a/retaliation.py +++ b/retaliation.py @@ -288,11 +288,11 @@ def read_url(url): return urllib2.urlopen(request).read() -def jenkins_get_responsible_user(job_name): +def jenkins_get_responsible_user(job_name, job_number): # Call back to Jenkins and determin who broke the build. (Hacky) # We do this by crudly parsing the changes on the last failed build - changes_url = JENKINS_SERVER + "/job/" + job_name + "/lastFailedBuild/changes" + changes_url = JENKINS_SERVER + "/job/" + job_name + "/" + job_number + "/changes" changedata = read_url(changes_url) # Look for the /user/[name] link @@ -318,7 +318,7 @@ def jenkins_wait_for_event(): status = notification_data["build"]["status"].upper() phase = notification_data["build"]["phase"].upper() if phase == "FINISHED" and status.startswith("FAIL"): - target = jenkins_get_responsible_user(notification_data["name"]) + target = jenkins_get_responsible_user(notification_data["name"], notification_data["build"]["number"]) if target == None: print "WARNING: Could not identify the user who broke the build!" continue