Skip to content

Instantly share code, notes, and snippets.

@vpavlin
Created April 13, 2017 22:49
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vpavlin/bab2ae47a2d844fbc3b8e8a9f8d444bd to your computer and use it in GitHub Desktop.
from saasherder.saasherder import SaasHerder
import requests
import json
builds = []
se = SaasHerder("services", "templates")
services = se.get_services("all")
for s in services:
url = s["url"].rstrip("/")
repo_list = url.split("/")
build_name = "devtools-%s-build-master" % (repo_list[-1])
if "launchpad" in repo_list[-1]:
build_name = "devtools-%s-generator-build-master" % (repo_list[-1])
elif "fabric8-ui" in repo_list[-1]:
build_name = "devtools-%s-npm-publish-build-master" % (repo_list[-1])
elif "saas" in repo_list[-1]:
continue
builds.append((s["name"], build_name))
for n, b in builds:
uri = "https://ci.centos.org/job/%s/api/json" % b
r = requests.get(uri)
p = b
try:
js = json.loads(r.content)
r2 = requests.get("%s/api/json" % js["lastSuccessfulBuild"]["url"])
js2 = json.loads(r2.content)
p += " %s" % (js2["result"])
if js2["result"] == "SUCCESS":
for a in js2["actions"]:
if "lastBuiltRevision" in a:
h = a["lastBuiltRevision"]["SHA1"]
print(h)
se.update("hash", n, h)
except ValueError as e:
pass
finally:
print p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment