本文整理汇总了Python中jenkins.Jenkins.enable_job方法的典型用法代码示例。如果您正苦于以下问题:Python Jenkins.enable_job方法的具体用法?Python Jenkins.enable_job怎么用?Python Jenkins.enable_job使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jenkins.Jenkins
的用法示例。
在下文中一共展示了Jenkins.enable_job方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from jenkins import Jenkins [as 别名]
# 或者: from jenkins.Jenkins import enable_job [as 别名]
class JobBuilder:
def __init__(self, jenkinsURL):
self.j = Jenkins(jenkinsURL)
self.jobName = ""
def add_job(self, jobName, configString):
self.jobName = jobName
if self.j.job_exists(jobName):
#Job exist in the job list
return False
else:
self.j.create_job(self.jobName, configString)
self.j.enable_job(self.jobName)
return True
def run_job(self, **params):
if self.jobName == "":
print "Have to add job firstly"
return False
else:
self.j.enable_job(self.jobName)
self.j.build_job(self.jobName, params)
示例2: __init__
# 需要导入模块: from jenkins import Jenkins [as 别名]
# 或者: from jenkins.Jenkins import enable_job [as 别名]
class TaskBuilder:
def __init__(self, jenkinsURL):
self.j = Jenkins(jenkinsURL)
self.jobName = ""
with open("config.xml") as file:
self.templateConfig = file.read()
self.template = Template(unicode(self.templateConfig))
def set_new_config(self, **params):
self.newConfig = self.template.render(repos=params['repos'], description=params['repos'])
def add_build(self, **params):
self.set_job_name(**params)
self.set_new_config(**params)
if self.j.job_exists(self.jobName):
self.do_build(**params)
else:
self.j.create_job(self.jobName, self.newConfig)
self.do_build(**params)
def do_build(self, **params):
self.set_job_name(**params)
self.set_new_config(**params)
self.j.enable_job(self.jobName)
self.j.build_job(self.jobName, {'branch': params['branch'], 'version': params['version'], 'package_list': params['package_list']})
def set_job_name(self,**params):
buildUtil = BuildUtil()
self.jobName = buildUtil.get_job_name(repos=params['repos'])
def get_build_status(self, **params):
#job_info = self.j.get_job_info(self.jobName)
#return build_status
pass
def get_job_name(self):
return self.jobName
示例3: JenkinsBot
# 需要导入模块: from jenkins import Jenkins [as 别名]
# 或者: from jenkins.Jenkins import enable_job [as 别名]
#.........这里部分代码省略.........
except JenkinsException as e:
return 'Oops, {0}'.format(e)
return 'Your job has been created: {0}/job/{1}'.format(
self.config['URL'], args[1])
@botcmd(split_args_with=None)
def jenkins_deletejob(self, mess, args):
"""Delete a Jenkins Job.
Example: !jenkins deletejob foo
"""
if len(args) < 1: # No job name
return 'Oops, I need the name of the job you want me to delete.'
self.connect_to_jenkins()
try:
self.jenkins.delete_job(args[0])
except JenkinsException as e:
return 'Oops, {0}'.format(e)
return 'Your job has been deleted.'
@botcmd(split_args_with=None)
def jenkins_enablejob(self, mess, args):
"""Enable a Jenkins Job.
Example: !jenkins enablejob foo
"""
if len(args) < 1: # No job name
return 'Oops, I need the name of the job you want me to enable.'
self.connect_to_jenkins()
try:
self.jenkins.enable_job(args[0])
except JenkinsException as e:
return 'Oops, {0}'.format(e)
return 'Your job has been enabled.'
@botcmd(split_args_with=None)
def jenkins_disablejob(self, mess, args):
"""Disable a Jenkins Job.
Example: !jenkins disablejob foo
"""
if len(args) < 1: # No job name
return 'Oops, I need the name of the job you want me to disable.'
self.connect_to_jenkins()
try:
self.jenkins.disable_job(args[0])
except JenkinsException as e:
return 'Oops, {0}'.format(e)
return 'Your job has been disabled.'
@botcmd(split_args_with=None)
def jenkins_createnode(self, mess, args):
"""Create a Jenkins Node with a JNLP Launcher with optionnal labels.
Example: !jenkins createnode runner-foo-laptop /home/foo # without labels
Example: !jenkins createnode runner-bar-laptop /home/bar linux docker # with labels
"""
if len(args) < 1: # No node name
return 'Oops, I need a name and a working dir for your new node.'
self.connect_to_jenkins()