本文整理汇总了Python中jenkins.Jenkins.get_queue_info方法的典型用法代码示例。如果您正苦于以下问题:Python Jenkins.get_queue_info方法的具体用法?Python Jenkins.get_queue_info怎么用?Python Jenkins.get_queue_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jenkins.Jenkins
的用法示例。
在下文中一共展示了Jenkins.get_queue_info方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_running_job
# 需要导入模块: from jenkins import Jenkins [as 别名]
# 或者: from jenkins.Jenkins import get_queue_info [as 别名]
def check_running_job(self):
#Check Running job
j = Jenkins(appconfig.jenkins_url)
job_list = j.get_jobs()
job_queue_list = j.get_queue_info()
running_job = []
for job in job_list:
if re.search('anime', job['color']):
running_job.append(job['name'])
for job_queue in job_queue_list:
running_job.append(job_queue['task']['name'])
return running_job
示例2: JenkinsBot
# 需要导入模块: from jenkins import Jenkins [as 别名]
# 或者: from jenkins.Jenkins import get_queue_info [as 别名]
#.........这里部分代码省略.........
"""Build a Jenkins Job with the given parameters
Example: !jenkins build test_project FOO:bar
"""
if len(args) == 0: # No Job name
return 'What job would you like to build?'
self.connect_to_jenkins()
params = self.build_parameters(args[1:])
# Is it a parameterized job ?
job = self.jenkins.get_job_info(args[0])
if job['actions'][0] == {} and job['actions'][1] == {}:
self.jenkins.build_job(args[0])
else:
self.jenkins.build_job(args[0], params)
running_job = self.search_job(args[0])
return 'Your job should begin shortly: {0}'.format(
self.format_jobs(running_job))
@botcmd(split_args_with=None)
def build(self, mess, args):
"""Shortcut for jenkins_build"""
return self.jenkins_build(mess, args)
@botcmd
def jenkins_unqueue(self, msg, args):
"""Cancel a queued job.
Example !jenkins unqueue foo
"""
self.connect_to_jenkins()
try:
queue = self.jenkins.get_queue_info()
job = next((job for job in queue if job['task']['name'].lower() == args.lower()), None)
if job:
self.jenkins.cancel_queue(job['id'])
return 'Unqueued job {0}'.format(job['task']['name'])
else:
return 'Could not find job {0}, but found the following: {1}'.format(
args, ', '.join(job['task']['name'] for job in queue))
except JenkinsException as e:
return 'Oops, {0}'.format(e)
@botcmd(split_args_with=None)
def jenkins_createjob(self, mess, args):
"""Create a Jenkins Job.
Example: !jenkins createjob pipeline foo [email protected]:foo/bar.git
"""
if len(args) < 2: # No Job type or name
return 'Oops, I need a type and a name for your new job.'
if args[0] not in ('pipeline', 'multibranch'):
return 'I\'m sorry, I can only create `pipeline` and \
`multibranch` jobs.'
self.connect_to_jenkins()
try:
if args[0] == 'pipeline':
self.jenkins.create_job(
args[1],
JENKINS_JOB_TEMPLATE_PIPELINE.format(repository=args[2]))