當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。