def _matching_builds(url, jobname, arch, distrover, branch=None): ''' Iterator: return builds of jobname, in newest-first order, that match arch/distrover/optional branch (if there are any). ''' job = Jenkins(url)[jobname] # get_build_ids() returns in newest-to-oldest order for buildno in job.get_build_ids(): build = job.get_build(buildno) build.lname = str(build).decode('utf-8', 'ignore') _set_branch(build) # set dist and arch later in the horrible _has_arch_distrover # if it's a matrix build, search the runs; if not, search parent. for run in build.get_matrix_runs(): run.lname = str(run).decode('utf-8', 'ignore') _set_branch(run) if _build_matches(run, arch, distrover, branch, is_matrix=True): yield run else: if _build_matches(build, arch, distrover, branch, is_matrix=False): yield build raise StopIteration