Skip to content

Commit

Permalink
Set up a custom sorting.
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaj committed Mar 17, 2015
1 parent 377c130 commit ce5334d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions checks.d/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,17 @@ def _get_build_metadata(self, dir_name):

def _get_build_results(self, instance_key, job_dir):
job_name = os.path.basename(job_dir)

try:
dirs = glob(os.path.join(job_dir, 'builds', '*_*'))
# versions of Jenkins > 1.597 dropped the timestamp-named folders
if len(dirs) == 0:
dirs = glob(os.path.join(job_dir, 'builds', '[0-9]*'))
if len(dirs) > 0:
dirs = sorted(dirs, reverse=True)
# versions of Jenkins > 1.597 need to be sorted by build number (integer)
try:
dirs = sorted(dirs, key=lambda x: int(x.split('/')[-1]), reverse=True)
except:
dirs = sorted(dirs, reverse=True)
# We try to get the last valid build
for index in xrange(len(dirs)):
dir_name = dirs[index]
Expand Down Expand Up @@ -142,6 +145,8 @@ def _get_build_results(self, instance_key, job_dir):
}

output.update(build_metadata)
if 'number' not in output:
output['number'] = dir_name.split('/')[-1]
self.high_watermarks[instance_key][job_name] = timestamp
self.log.debug("Processing %s results '%s'" % (job_name, output))

Expand Down

0 comments on commit ce5334d

Please sign in to comment.