blob: 8be500bba0ae1dead771c4bf84b9106da71340f6 [file] [log] [blame]
Anthony Youngd99f5fd2011-11-14 11:05:04 -08001#!/usr/bin/python
Masayuki Igawa46c688c2014-02-24 18:42:37 +09002
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
Anthony Youngd99f5fd2011-11-14 11:05:04 -080015import json
16import sys
Masayuki Igawa46c688c2014-02-24 18:42:37 +090017import urllib
Anthony Youngd99f5fd2011-11-14 11:05:04 -080018
19
20def print_usage():
zhang-jinnan8829aca2014-03-03 10:55:33 +080021 print("Usage: %s [jenkins_url (eg. http://50.56.12.202:8080/)]"
22 % sys.argv[0])
Anthony Youngd99f5fd2011-11-14 11:05:04 -080023 sys.exit()
24
25
26def fetch_blob(url):
27 return json.loads(urllib.urlopen(url + '/api/json').read())
28
29
30if len(sys.argv) < 2:
31 print_usage()
32
33BASE_URL = sys.argv[1]
34
35root = fetch_blob(BASE_URL)
36results = {}
37for job_url in root['jobs']:
38 job = fetch_blob(job_url['url'])
39 if job.get('activeConfigurations'):
40 (tag, name) = job['name'].split('-')
41 if not results.get(tag):
42 results[tag] = {}
43 if not results[tag].get(name):
44 results[tag][name] = []
45
46 for config_url in job['activeConfigurations']:
47 config = fetch_blob(config_url['url'])
48
49 log_url = ''
50 if config.get('lastBuild'):
51 log_url = config['lastBuild']['url'] + 'console'
52
53 results[tag][name].append({'test': config['displayName'],
54 'status': config['color'],
55 'logUrl': log_url,
56 'healthReport': config['healthReport']})
57
Masayuki Igawa46c688c2014-02-24 18:42:37 +090058print(json.dumps(results))