コード例 #1
0
def get_builds(jenkins_url, job, days_back=2):
    log.info("Getting builds for <{0}>".format(job))

    rng = jenkins.get_job_build_range(jenkins_url, job)
    stopline = util.days_ago_timestamp(7)

    builds = {}
    for i in rng:
        try:
            upstream_build, build = get_build_info(jenkins_url, job, i)
        except Exception:
            continue

        # orphan build without upstream build. skip it
        if not upstream_build:
            continue

        timestamp = build['timestamp'] / 1000

        if timestamp < stopline:
            stopline_str = util.timestamp2str(timestamp)
            log.info("Stop line {0} for job {1}".format(stopline_str, job))
            break

        upstream_number = upstream_build["upstreamBuild"]

        if should_insert_newer_build(builds, build, upstream_number):
            builds[upstream_number] = build

    return builds
コード例 #2
0
def query_main_job(jenkins_url, job):
    log.info("Getting main job {0}".format(job))
    rng = jenkins.get_job_build_range(jenkins_url, job)
    stopline = util.days_ago_timestamp(7)

    builds = {}
    for n in rng:
        try:
            raw = jenkins.get_build(jenkins_url, job, n, short=True)
        except Exception:
            continue

        timestamp = raw["timestamp"] / 1000
        if timestamp < stopline:
            stopline_str = util.timestamp2str(timestamp)
            log.info("Stop line {0} for job {1}".format(stopline_str, job))
            break

        number, processed_values = process_raw_build(raw)
        builds[number] = processed_values

    return builds