本文整理汇总了Python中autojenkins.Jenkins.create_copy方法的典型用法代码示例。如果您正苦于以下问题:Python Jenkins.create_copy方法的具体用法?Python Jenkins.create_copy怎么用?Python Jenkins.create_copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autojenkins.Jenkins
的用法示例。
在下文中一共展示了Jenkins.create_copy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_job
# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import create_copy [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
示例2: create_job
# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import create_copy [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
示例3: run_jenkins
# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import create_copy [as 别名]
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)
示例4: Jenkins
# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import create_copy [as 别名]
#!/usr/bin/python
import time
from autojenkins import Jenkins
j = Jenkins('http://192.168.1.216:8080/')
# Create a new job.
j.create_copy('my-new-job', 'Selenium-Test', repo='my-repo', branch='my-branch')
newjob = j.job_info('my-new-job')
while newjob != 'null':
print 'Job Created Successfully'
break
else:
time.sleep(1)
示例5: Jenkins
# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import create_copy [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')
示例6: TestJenkins
# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import create_copy [as 别名]
#.........这里部分代码省略.........
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'),
'apache-solr-4.0-2012-02-29_09-07-30-src.tgz'),
])
def checks_get_config_xml(self, response):
self.assertTrue(response.startswith('<?xml'))
self.assertTrue(response.endswith('</project>'))
# TODO: test job creation, and set_config_xml
def test_create(self, requests):
requests.post.return_value = mock_response()
config_xml = path.join(fixture_path, 'create_copy.txt')
self.jenkins.create('job', config_xml, value='2')
CFG = "<value>2</value><disabled>true</disabled>"
requests.post.assert_called_once_with(
'http://jenkins/createItem',
auth=None,
headers={'Content-Type': 'application/xml'},
params={'name': 'job'},
data=CFG,
verify=True)
def test_create_copy(self, requests):
requests.get.return_value = mock_response('create_copy.txt')
requests.post.return_value = mock_response()
self.jenkins.create_copy('job', 'template', value='2')
CFG = "<value>2</value><disabled>false</disabled>"
requests.post.assert_called_once_with(
'http://jenkins/createItem',
auth=None,
headers={'Content-Type': 'application/xml'},
params={'name': 'job'},
data=CFG,
verify=True)
def test_transfer(self, requests):
requests.get.return_value = mock_response('transfer.txt')
requests.post.return_value = mock_response()
self.jenkins.transfer('job', 'http://jenkins2')
CFG = load_fixture('transfer.txt')
requests.post.assert_called_once_with(
'http://jenkins2/createItem',
auth=None,
headers={'Content-Type': 'application/xml'},
示例7: __init__
# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import create_copy [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)