Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use build number to construct call back URL #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions retaliation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down