forked from openshiftio/saas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins-update.py
52 lines (42 loc) · 1.4 KB
/
jenkins-update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from saasherder.saasherder import SaasHerder
import requests
import json
service_dirs = ["dsaas-services"]
def update(service_dir, output_dir):
builds = []
print("Directory: " +service_dir)
se = SaasHerder(service_dir, output_dir)
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:
print("Build: %s" % b)
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("Found hash: %s" % h)
se.update("hash", n, h)
except ValueError as e:
pass
finally:
print
for d in service_dirs:
update(d, "%s-templates" % d.split("-")[-1])