Skip to content

Instantly share code, notes, and snippets.

@denik
Created February 19, 2013 14:00
Show Gist options
  • Save denik/4986151 to your computer and use it in GitHub Desktop.
Save denik/4986151 to your computer and use it in GitHub Desktop.
prints a number: last travis build for current branch
#!/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