Created
February 19, 2013 14:00
-
-
Save denik/4986151 to your computer and use it in GitHub Desktop.
prints a number: last travis build for current branch
This file contains hidden or 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
#!/usr/bin/python | |
import sys | |
import re | |
import subprocess | |
popen = subprocess.Popen("travis history --branch `git rev-parse --abbrev-ref HEAD` --limit 1", stderr=subprocess.PIPE, | |
stdout=subprocess.PIPE, shell=True) | |
out, err = popen.communicate() | |
try: | |
if popen.poll() != 0: | |
sys.exit('%r died with code %r' % (popen.pid, popen.poll())) | |
build = int(re.match('^#(\d+)', out).group(1)) | |
except: | |
sys.stderr.write(err) | |
sys.stdout.write(out) | |
raise | |
else: | |
print build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment