Answering my own questions:
On 17/01/2013 11:48, Chris Withers wrote:
Also, how can I compute a fingerprint of a tarball outside Jenkins in
order to have something to pump into the above process?
In python, this is as simple as:
>>> from hashlib import md5
>>> m = md5()
>>> m.update(open('D:/Download/checker-1.7 (1).tar.gz', 'rb').read())
>>> fingerprint = m.hexdigest()
>>> fingerprint
'85b6dc942d7cf896317ed424a21bd80f'
How would I interrogate a Jenkins instant with a fingerprint using the
REST api in order to find what jobs have processed the artifact the
fingerprint belongs to,
This is all in:
>>> jenkins_url = 'http://jenkins.simplistix.co.uk/'
>>> fingerprint = '85b6dc942d7cf896317ed424a21bd80f'
>>> from urllib import urlopen
>>> from json import loads
>>> usage=
loads(urlopen(jenkins_url+'/fingerprint/'+fingerprint+'/api/json').re
ad())['usage']
and that all the tests have passed in jobs that
have processed the artifact.
>>> for job in usage:
... for r in job['ranges']['ranges']:
... for i in range(r['start'], r['end']):
... data=loads(
... urlopen('%s/job/%s/%i/testReport/api/json' % ( ...
jenkins_url, job['name'], i)).read()
... )
... print data['passCount'],
... print data['failCount'],
... print data['skipCount']
...
26 0 0
26 0 0
26 0 0
34 0 0
26 0 0
26 0 0
26 0 0
26 0 0
26 0 0
26 0 0
Curious, though, why does the 'ranges' element in the usage appear to
always be made up of one key also called 'ranges' pointing to a list of
mappings containing the start and end point for the range?
cheers,
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk