本文整理汇总了Python中autojenkins.Jenkins.all_jobs方法的典型用法代码示例。如果您正苦于以下问题:Python Jenkins.all_jobs方法的具体用法?Python Jenkins.all_jobs怎么用?Python Jenkins.all_jobs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autojenkins.Jenkins
的用法示例。
在下文中一共展示了Jenkins.all_jobs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_jobs
# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import all_jobs [as 别名]
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))
示例2: list_jobs
# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import all_jobs [as 别名]
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)
示例3: list_jobs
# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import all_jobs [as 别名]
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))
示例4: Jenkins
# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import all_jobs [as 别名]
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"
#j.wait_for_build("CodeWarrior_Build_Test")
示例5: TestJenkins
# 需要导入模块: from autojenkins import Jenkins [as 别名]
# 或者: from autojenkins.Jenkins import all_jobs [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'),
#.........这里部分代码省略.........