当前位置: 首页>>代码示例>>Python>>正文


Python autojenkins.Jenkins类代码示例

本文整理汇总了Python中autojenkins.Jenkins的典型用法代码示例。如果您正苦于以下问题:Python Jenkins类的具体用法?Python Jenkins怎么用?Python Jenkins使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Jenkins类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build_job

def build_job(host, jobname, options):
    """
    Trigger build for an existing job.

    If the wait option is specified, wait until build completion

    :returns:

        A boolean value indicating success:

         * If wait: ``True`` if build was successful, ``False`` otherwise
         * If not wait: ``True`` if HTTP status code is not an error code
    """
    print ("Start building job '{0}'".format(jobname))
    jenkins = Jenkins(host, proxies=get_proxy(options), auth=get_auth(options))
    try:
        response = jenkins.build(jobname, wait=options['--wait'])
        if options['--wait']:
            result = response['result']
            print('Result = "{0}"'.format(result))
            return result == 'SUCCESS'
        else:
            print("Build '%s' started" % jobname)
            return response.status_code < 400
    except (jobs.JobInexistent, jobs.JobNotBuildable) as error:
        print("Error:", error.msg)
        return False
开发者ID:ThomasGriffinx,项目名称:autojenkins,代码行数:27,代码来源:run.py

示例2: list_jobs

def list_jobs(host, options, color=True, raw=False):
    """
    List all jobs
    """
    if raw:
        FORMAT = "{1}"
        position = 0
    elif color:
        FORMAT = "\033[{0}m{1}\033[0m"
        position = 0
    else:
        FORMAT = "{0:<10} {1}"
        position = 1
    if not raw:
        print ("All jobs in {0}".format(host))
    jenkins = Jenkins(host, proxies=get_proxy(options), auth=get_auth(options))
    joblist = jenkins.all_jobs()
    for name, color in joblist:
        if '_' in color:
            color = color.split('_')[0]
            building = True
        else:
            building = False
        prefix = '' if raw else '* ' if building else '  '
        out = COLOR_MEANING[color][position]
        print(prefix + FORMAT.format(out, name))
开发者ID:ThomasGriffinx,项目名称:autojenkins,代码行数:26,代码来源:run.py

示例3: create_job

def create_job(host, jobname, options):
    """
    Create a new job
    """
    data = get_variables(options["-D"])

    print(
        """
    Creating job '{0}' from template '{1}' with:
      {2}
    """.format(
            jobname, options["<template>"], data
        )
    )

    jenkins = Jenkins(host, proxies=get_proxy(options), auth=get_auth(options))
    try:
        response = jenkins.create_copy(jobname, options["<template>"], **data)
        if response.status_code == 200 and options["--build"]:
            print("Triggering build.")
            jenkins.build(jobname)
        print("Job URL: {0}".format(jenkins.job_url(jobname)))
        return response.status_code < 400
    except jobs.JobExists as error:
        print("Error:", error.msg)
        return False
开发者ID:txels,项目名称:autojenkins,代码行数:26,代码来源:run.py

示例4: delete_jobs

def delete_jobs(host, jobnames):
    """
    Delete existing jobs.
    """
    for jobname in jobnames:
        print ("Deleting job '{0}'".format(jobname))
        jenkins = Jenkins(host)
        response = jenkins.delete(jobname)
        print(response.status_code)
开发者ID:baseblack,项目名称:autojenkins,代码行数:9,代码来源:run.py

示例5: delete_job

def delete_job(host, jobname):
    """
    Delete an existing job
    """
    print ("Deleting job '{0}'".format(jobname))

    jenkins = Jenkins(host)
    response = jenkins.delete(jobname)
    print('Status: {0}'.format(response.status_code))
开发者ID:pombredanne,项目名称:autojenkins,代码行数:9,代码来源:run.py

示例6: delete_jobs

def delete_jobs(host, jobnames, options):
    """
    Delete existing jobs.
    """
    jenkins = Jenkins(host, auth=get_auth(options))
    for jobname in jobnames:
        print ("Deleting job '{0}'".format(jobname))
        response = jenkins.delete(jobname)
        print(response.status_code)
开发者ID:askedrelic,项目名称:autojenkins,代码行数:9,代码来源:run.py

示例7: delete_jobs

def delete_jobs(host, jobnames, options):
    """
    Delete existing jobs.
    """
    jenkins = Jenkins(host, proxies=get_proxy(options), auth=get_auth(options))
    for jobname in jobnames:
        print ("Deleting job '{0}'".format(jobname))
        try:
            response = jenkins.delete(jobname)
            if response.status_code == 200:
                print("Job '%s' deleted" % jobname)
        except jobs.JobInexistent as error:
            print("Error:", error.msg)
            print("Error:", error.msg)
        except (jobs.HttpForbidden, jobs.HttpUnauthorized):
            pass
开发者ID:ThomasGriffinx,项目名称:autojenkins,代码行数:16,代码来源:run.py

示例8: create_job

def create_job(host, jobname, options):
    """
    Create a new job
    """
    data = get_variables(options)

    print ("""
    Creating job '{0}' from template '{1}' with:
      {2}
    """.format(jobname, options.template, data))

    jenkins = Jenkins(host)
    response = jenkins.create_copy(jobname, options.template, **data)
    if response.status_code == 200 and options.build:
        print('Triggering build.')
        jenkins.build(jobname)
    return response.status_code
开发者ID:pombredanne,项目名称:autojenkins,代码行数:17,代码来源:run.py

示例9: list_jobs

def list_jobs(host):
    """
    List all jobs
    """
    COLOR = "\033[{0}m"
    COLORCODE = { 
        'blue': '1;34', 
        'red': '1;31', 
        'yellow': '1;33', 
        'aborted': '1;37',
        'disabled': '0;37',
        'grey': '1;37',
    }

    print ("All jobs in {0}".format(host))
    jenkins = Jenkins(host)
    jobs = jenkins.all_jobs()
    for name, color in jobs:
        print(COLOR.format(COLORCODE[color.split('_')[0]]) + name)
开发者ID:pombredanne,项目名称:autojenkins,代码行数:19,代码来源:run.py

示例10: run_jenkins

def run_jenkins(host, jobname, options):
    spliteq = lambda x: x.split("=")
    data = dict(map(spliteq, options.D))

    print(
        """
    Creating job '{0}' from template '{1}' with:
      {2}
    """.format(
            jobname, options.template, data
        )
    )

    jenkins = Jenkins(host)
    response = jenkins.create_copy(jobname, options.template, **data)
    print("Status: {0}".format(response.status_code))
    if response.status_code == 200 and options.build:
        print("Triggering build.")
        j.build(jobname)
开发者ID:ealliaume,项目名称:autojenkins,代码行数:19,代码来源:run.py

示例11: __init__

 def __init__(self):
     self.jenkins_url = jenkins_config.get('url')
     self.user = jenkins_config.get('user')
     self.password = jenkins_config.get('password')
     if self.jenkins_url is not None:
         try:
             self.jenkins = Jenkins(
                 self.jenkins_url, auth=(self.user, self.password))
         except Exception as e:
             log_error(e)
开发者ID:xiaomatech,项目名称:ops,代码行数:10,代码来源:jenkins.py

示例12: list_jobs

def list_jobs(host, color=True):
    """
    List all jobs
    """
    if color:
        FORMAT = "\033[{0}m{1}\033[0m"
        position = 0
    else:
        FORMAT = "{0:<10} {1}"
        position = 1
    print ("All jobs in {0}".format(host))
    jenkins = Jenkins(host)
    jobs = jenkins.all_jobs()
    for name, color in jobs:
        if '_' in color:
            color = color.split('_')[0]
            building = True
        else:
            building = False
        prefix = '* ' if building else '  '
        out = COLOR_MEANING[color][position]
        print(prefix + FORMAT.format(out, name))
开发者ID:OddBloke,项目名称:autojenkins,代码行数:22,代码来源:run.py

示例13: build_job

def build_job(host, jobname, options):
    """
    Trigger build for an existing job.

    If the wait option is specified, wait until build completion

    :returns:

        A boolean value indicating success:

         * If wait: ``True`` if build was successful, ``False`` otherwise
         * If not wait: ``True`` if HTTP status code is not an error code
    """
    print ("Start building job '{0}'".format(jobname))

    jenkins = Jenkins(host, auth=get_auth(options))
    response = jenkins.build(jobname, wait=options.wait)
    if options.wait:
        result = response['result']
        print('Result = "{0}"'.format(result))
        return result == 'SUCCESS'
    else:
        return response.status_code < 400
开发者ID:askedrelic,项目名称:autojenkins,代码行数:23,代码来源:run.py

示例14: Jenkins

#!/usr/bin/python
import time
from autojenkins import Jenkins
 
j = Jenkins('http://192.168.1.216:8080/')

# Build new job.
print "Building Job"
j.build('my-new-job')

while  j.job_info('my-new-job')['color'] == 'notbuilt' or j.job_info('my-new-job')['color'] == 'notbuilt_anime':
	#print j.job_info('my-new-job')['color']
	time.sleep(1)
	if j.job_info('my-new-job')['color'] == 'blue' or j.job_info('my-new-job')['color'] == 'yellow' or j.job_info('my-new-job')['color'] == 'red':
		#print j.job_info('my-new-job')['color']
		print 'Build Completed'
		break

if j.last_result('my-new-job')['result'] == 'SUCCESS':
	print 'Job was built successfully'
else:
	print 'Build failed'	
开发者ID:oneshore,项目名称:jenkins-selenium-example,代码行数:22,代码来源:buildandcheck.py

示例15: Jenkins

import os,sys
sys.path.extend(os.path.dirname(os.path.realpath(__file__)))
#http://www.cnblogs.com/huangcong/archive/2011/08/29/2158268.html


date_regexp = re.compile("(\d+-\d+-\d+)")

jobHash = {}





if __name__ == '__main__':
    j = Jenkins('http://135.251.224.94:8080/')
    jobs = j.all_jobs()
    print(jobs)

    for job, color in jobs:
        if color in ['red', 'blue', 'yellow']:
            full_info = j.job_info(job)
            last_build = j.last_build_info(job)
            when = datetime.fromtimestamp(last_build['timestamp'] / 1000)
        else:
            when = '(unknown)'
        print("{0!s:<19} {1:<6} {2}".format(when, color, job))

    #print "Build!"
    #j.build("CodeWarrior_Build_Test")
    #print "Waiting"
开发者ID:nuaays,项目名称:AutomateJenkins,代码行数:30,代码来源:demo_run_new_createjob.py


注:本文中的autojenkins.Jenkins类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。