Skip to content

Instantly share code, notes, and snippets.

@busbey
Last active October 11, 2017 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save busbey/ff5f7ae3a292164cc110fdb934935c8c to your computer and use it in GitHub Desktop.
Save busbey/ff5f7ae3a292164cc110fdb934935c8c to your computer and use it in GitHub Desktop.
>>> import jenkins
>>> server = jenkins.Jenkins('https://builds.apache.org/')
>>> job_info = server.get_job_info('PreCommit-HBASE-Build', 1, True)
>>> builds = [catch(lambda : server.get_build_info('PreCommit-HBASE-Build', x['number'])) for x in job_info['builds']]
>>> for build in builds:
... if build['result'] == 'SUCCESS':
... host_counts[build['builtOn']]['success']+=1
... elif build['result'] == 'FAILURE':
... for test_log in [artifact for artifact in build['artifacts'] if artifact['fileName'].startswith('patch-unit')]:
... try:
... if server.jenkins_open(build['url'] + "artifact/" + test_log['relativePath']).lower().find('timeout') != -1 :
... host_counts[build['builtOn']]['timeout']+=1
... break
... except Exception:
... pass
... else:
... host_counts[build['builtOn']]['failure']+=1
>>> print host_counts
defaultdict(<function <lambda> at 0x10c0c2410>, {u'H1': {'failure': 6, 'timeout': 14, 'success': 6}, u'H2': {'failure': 24, 'timeout': 35, 'success': 18}, u'H3': {'failure': 0, 'timeout': 1, 'success': 0}, u'H12': {'failure': 3, 'timeout': 3, 'success': 1}, u'H13': {'failure': 6, 'timeout': 2, 'success': 1}, u'H6': {'failure': 1, 'timeout': 4, 'success': 4}, u'H4': {'failure': 2, 'timeout': 0, 'success': 1}, u'H5': {'failure': 3, 'timeout': 1, 'success': 1}, u'H10': {'failure': 19, 'timeout': 8, 'success': 4}, u'H9': {'failure': 11, 'timeout': 7, 'success': 2}, u'H11': {'failure': 2, 'timeout': 0, 'success': 0}, u'H26': {'failure': 1, 'timeout': 0, 'success': 0}, None: {'failure': 2, 'timeout': 0, 'success': 0}, u'H0': {'failure': 11, 'timeout': 15, 'success': 10}})
Host % timeout Success Timeout Failure General Failure
H0 42% 10 15 11
H1 54% 6 14 6
H2 45% 18 35 24
H3 100% 0 1 0
H4 0% 1 0 2
H5 20% 1 1 3
H6 44% 4 4 1
H9 35% 2 7 11
H10 26% 4 8 19
H11 0% 0 0 2
H12 43% 1 3 3
H13 22% 1 2 6
H26 0% 0 0 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment