Python-Jenkins 查询job是否存在
def check_jobs_from_jenkins(job_names): if isinstance(job_names, str): job_names = [job_names] job_dict = {} for job_name in job_names: job_dict[job_name] = True if is_job_exists(job_name) else False return job_dict def get_jenkins(): return jenkins.Jenkins(get_ci_url(), get_ci_user(), get_ci_password()) def is_job_exists(job_name): j = get_jenkins() try: j.assert_job_exists(job_name) logging.info('----- is_job_exists::%s::True-----' % job_name) return True except jenkins.JenkinsException: logging.info('----- is_job_exists::%s::False-----' % job_name) return False finally: pass
posted on 2015-09-25 11:02 sdet_liang 阅读(1033) 评论(0) 编辑 收藏 举报