示例#1
0
                           type=str,
                           help='timezone for inputs')

    args = argParser.parse_args()

    jmdb = JenkinsMongoDB()

    if len(args.builds):
        if len(args.jobs) != 1:
            raise ValueError("If --bnum only one --job allowed")

        # Re-parse only specific builds from a job

        # validate the job/builds
        job_name = args.jobs[0]
        active_jobs = jmdb.active_jobs()
        if job_name not in active_jobs:
            raise ValueError("{} is not an active job".format(job_name))

        meta_coll = JenkinsJobMetaCollection(job_name=job_name, jmdb=jmdb)
        all_builds = meta_coll.all_builds()
        for bnum in args.builds:
            if bnum not in all_builds:
                raise ValueError("{} is not a valid build number".format(bnum))

        # See if user wants to proceed
        if not args.force:
            foo = input("Proceed (y/N): ")
            if foo != 'y':
                sys.exit(0)
示例#2
0
    jenkins_host=cfg.get('JENKINS_HOST')
    if not jenkins_host:
        raise ValueError("JENKINS_HOST not defined")
    logger.info("using jenkins_host {}".format(jenkins_host))

    force_default_job_update = False
    job_list = args.update_jobs
    if not job_list:
        logger.info("no job list, fetching all known jobs")
        japi = JenkinsApi(host=jenkins_host)
        job_list = japi.list_jobs()

        # Update the active jobs and active hosts lists in the DB
        logger.info("updating active jobs list in DB")
        jmdb.active_jobs(job_list=job_list)
        logger.info("updating active hosts list in DB")
        jmdb.active_hosts(host_list=japi.list_hosts())

        # Since we're doing the full list, see if we need to force
        # a default update of job stats.  A force update will ensure the
        # job stats are maintained even if there are no recent builds for
        # that job. (ENG-8959)
        ts = jmdb.all_job_update_ts()
        if int(time.time()) > ts:
            force_default_job_update = True

    logger.info("job list: {}".format(job_list))
    logger.info("force_default_job_update: {}"
                .format(force_default_job_update))