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) print("proceeding...") # Flag builds for re-parse process_lock_name = "{}_process_lock".format(job_name) process_lock_meta = {"reason": "locked by reparse_builds.py"} process_lock = MongoDBKeepAliveLock(db=jmdb.jenkins_db(), name=process_lock_name) try: process_lock.lock(meta=process_lock_meta) except MongoDBKALockTimeout as e: raise Exception("timeout acquiring {}".format(process_lock_name)) meta_coll.reparse(builds=args.builds) process_lock.unlock() sys.exit(0) # Re-parse builds selected by time period, optionally filtered by job name(s) tz = pytz.timezone(args.tz) now = datetime.datetime.now(tz=tz) default_start_date = "{}-{}-{}".format(now.year, now.month, now.day)
argParser = argparse.ArgumentParser() argParser.add_argument("--job", default=[], type=str, action='append', dest='jobs', help="only reset this (these) job(s)", metavar="name") argParser.add_argument("--do_reset", action="store_true", help="do the reset") args = argParser.parse_args() jmdb = JenkinsMongoDB() db = jmdb.jenkins_db() for meta in db.job_meta_collection_names(): if args.jobs: # Special knowledge... fields = meta.split('_') job = "_".join(fields[1:-1]) if job not in args.jobs: continue if not args.do_reset: print("would reset: {}".format(meta)) continue print("resetting {}".format(meta)) db.collection(meta).find_one_and_delete({'_id': 'retry'})
}, 'JENKINS_DB_NAME': { 'default': None } }) # It's log, it's log... :) logging.basicConfig( level=cfg.get('LOG_LEVEL'), format= "'%(asctime)s - %(threadName)s - %(funcName)s - %(levelname)s - %(message)s", handlers=[logging.StreamHandler()]) logger = logging.getLogger(__name__) JMDB = JenkinsMongoDB() DB = JMDB.jenkins_db().db if __name__ == "__main__": import argparse argParser = argparse.ArgumentParser() argParser.add_argument( '--outdir', required=True, type=str, help='path to directory where per-job data should be written') args = argParser.parse_args() os.makedirs(args.outdir, exist_ok=True) for cname in DB.list_collection_names():