Created
August 23, 2011 13:44
-
-
Save vmalloc/1165155 to your computer and use it in GitHub Desktop.
Script to poll a jenkins job and run growlnotify with the status at its end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import argparse | |
import urllib2 | |
import lxml.etree | |
import subprocess | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--sleep", default=1, type=int) | |
parser.add_argument("server") | |
parser.add_argument("job") | |
if __name__ == '__main__': | |
args = parser.parse_args() | |
while True: | |
xml = lxml.etree.fromstring(urllib2.urlopen("http://{args.server}/job/{args.job}/api/xml".format(args=args)).read()) | |
[status] = xml.xpath("color/text()") | |
if status in ("blue", "red"): | |
subprocess.Popen("growlnotify -s -t \"{}\" -m \"Build {}\"".format( | |
args.job, "succeessful" if status == "blue" else "failed" | |
), shell=True) | |
break | |
time.sleep(args.sleep) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment