码迷,mamicode.com
首页 > 编程语言 > 详细

Python-Jenkins 查询job是否存在

时间:2015-09-25 12:43:49      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:

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

 

Python-Jenkins 查询job是否存在

标签:

原文地址:http://www.cnblogs.com/liangnote/p/4837573.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!