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


Python Jenkins.build方法代码示例

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


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

示例1: create_job

# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import build [as 别名]
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,代码行数:28,代码来源:run.py

示例2: build_job

# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import build [as 别名]
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,代码行数:29,代码来源:run.py

示例3: create_job

# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import build [as 别名]
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,代码行数:19,代码来源:run.py

示例4: build_job

# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import build [as 别名]
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,代码行数:25,代码来源:run.py

示例5: Jenkins

# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import build [as 别名]
from autojenkins import Jenkins

j = Jenkins('http://jenkins.live')
result = j.build('mbf-order-dcs-us677_merge_dev_carles', wait=True)
print('Result = ' + result['result'])
开发者ID:B-Rich,项目名称:autojenkins,代码行数:7,代码来源:build_wait.py

示例6: Jenkins

# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import build [as 别名]
#!/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,代码行数:24,代码来源:buildandcheck.py

示例7: Jenkins

# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import build [as 别名]
from autojenkins import Jenkins


if __name__ == '__main__':
    j = Jenkins('http://jenkins.pe.local')
    # dir = path.dirname(path.dirname(__file__))
    # config_file = path.join(dir, 'templates/story-dev-job.xml')
    response = j.delete('aaa')
    response = j.create_copy('aaa', 'template',
                             repo='mbf-warehouse-screens',
                             branch='us544_login',
                             package='warehouse_screens')
    print(response.status_code)
    if response.status_code == 200:
        j.build('aaa')
开发者ID:OddBloke,项目名称:autojenkins,代码行数:17,代码来源:test_run.py

示例8: TestJenkins

# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import build [as 别名]
class TestJenkins(TestCase):

    def setUp(self):
        super(TestJenkins, self).setUp()
        self.jenkins = Jenkins('http://jenkins')

    def test_all_jobs(self, requests):
        response = {'jobs': [{'name': 'job1', 'color': 'blue'}]}
        requests.get.return_value = mock_response(response)
        jobs = self.jenkins.all_jobs()
        requests.get.assert_called_once_with('http://jenkins/api/python',
                                             verify=True,
                                             auth=None)
        self.assertEqual(jobs, [('job1', 'blue')])

    def test_get_job_url(self, *args):
        url = self.jenkins.job_url('job123')
        self.assertEqual('http://jenkins/job/job123', url)

    def test_last_result(self, requests, *args):
        second_response = Mock(status_code=200)
        second_response.content = "{'result': 23}"
        requests.get.side_effect = [
            mock_response('job_info.txt'), second_response
        ]
        response = self.jenkins.last_result('name')
        self.assertEqual(23, response['result'])
        self.assertEqual(
            (('https://builds.apache.org/job/Solr-Trunk/1783/api/python',),
             {'auth': None, 'verify': True}),
            requests.get.call_args_list[1]
        )

    @data(
        ('job_info', 'job/{0}/api/python'),
        ('last_build_info', 'job/{0}/lastBuild/api/python'),
        ('last_build_report', 'job/{0}/lastBuild/testReport/api/python'),
        ('last_success', 'job/{0}/lastSuccessfulBuild/api/python'),
        ('get_config_xml', 'job/{0}/config.xml'),
    )
    def test_get_methods_with_jobname(self, case, requests):
        method, url = case
        requests.get.return_value = mock_response('{0}.txt'.format(method))
        response = getattr(self.jenkins, method)('name')
        requests.get.assert_called_once_with(
            'http://jenkins/' + url.format('name'),
            verify=True,
            auth=None)
        getattr(self, 'checks_{0}'.format(method))(response)

    def test_build_info(self, requests):
        url = 'job/name/3/api/python'
        requests.get.return_value = mock_response('last_build_info.txt')
        self.jenkins.build_info('name', 3)
        requests.get.assert_called_once_with(
            'http://jenkins/' + url,
            verify=True,
            auth=None)

    def check_result(self, response, route, value):
        for key in route:
            response = response[key]
        self.assertEqual(response, value)

    def check_results(self, response, values):
        for route, value in values:
            self.check_result(response, route, value)

    def checks_job_info(self, response):
        self.check_results(
            response,
            [(('color',), 'red'),
             (('lastSuccessfulBuild', 'number'), 1778),
             (('lastSuccessfulBuild', 'url'),
              'https://builds.apache.org/job/Solr-Trunk/1778/'),
            ])

    def checks_last_build_info(self, response):
        self.check_results(
            response,
            [(('timestamp',), 1330941036216L),
             (('number',), 1783),
             (('result',), 'FAILURE'),
             (('changeSet', 'kind'), 'svn'),
            ])

    def checks_last_build_report(self, response):
        self.check_results(
            response,
            [(('duration',), 692.3089),
             (('failCount',), 1),
             (('suites', 0, 'name'), 'org.apache.solr.BasicFunctionalityTest'),
            ])

    def checks_last_success(self, response):
        self.check_results(
            response,
            [(('result',), 'SUCCESS'),
             (('building',), False),
             (('artifacts', 0, 'displayPath'),
#.........这里部分代码省略.........
开发者ID:Mondego,项目名称:pyreco,代码行数:103,代码来源:allPythonContent.py

示例9: __init__

# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import build [as 别名]
class jenkins:
    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)

    def help(self, req, resp):
        h = '''
                                jenkins CI

                    ops jenkins create_copy -j job -t template -r repo -b branch -p package

                    ops jenkins result -j job
                    ops jenkins info -t template
                    ops jenkins build -j job

                    ops jenkins enable -j job
                    ops jenkins disable -j job
                    ops jenkins delete -j job
        '''
        return h

    def result(self, req, resp):
        job = req.get_param(name='j')
        if job is None:
            return '-j(job) need'
        return self.jenkins.last_result(job)['result']

    def info(self, req, resp):
        template = req.get_param(name='t')
        if template is None:
            return '-t(template) need'
        return self.jenkins.get_config_xml(template)

    def create_copy(self, req, resp):
        job = req.get_param(name='j')
        template = req.get_param(name='t')
        repo = req.get_param(name='r')
        branch = req.get_param(name='b')
        package = req.get_param(name='p')
        if job is None:
            return '-j(job) need'
        if template is None:
            return '-t(template) need'
        if repo is None:
            return '-r(repo) need'
        if branch is None:
            return '-b(branch) need'
        if package is None:
            return '-p(package) need'
        return self.jenkins.create_copy(
            job, template, repo=repo, branch=branch, package=package)

    def build(self, req, resp):
        job = req.get_param(name='j')
        if job is None:
            return '-j(job) need'
        return self.jenkins.build(job)

    def enable(self, req, resp):
        job = req.get_param(name='j')
        if job is None:
            return '-j(job) need'
        return self.jenkins.enable(job)

    def disable(self, req, resp):
        job = req.get_param(name='j')
        if job is None:
            return '-j(job) need'
        return self.jenkins.disable(job)

    def delete(self, req, resp):
        job = req.get_param(name='j')
        if job is None:
            return '-j(job) need'
        return self.jenkins.delete(job)
开发者ID:xiaomatech,项目名称:ops,代码行数:84,代码来源:jenkins.py


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