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


Python Jenkins.job_create方法代码示例

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


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

示例1: jenkins

# 需要导入模块: from jenkins import Jenkins [as 别名]
# 或者: from jenkins.Jenkins import job_create [as 别名]
def jenkins():
    print('Looking for a running Jenkins instance')
    webapi = Jenkins('http://127.0.0.1:60888')

    print('Removing all jobs ...')
    for job in webapi.jobs:
        webapi.job_delete(job.name)

    print('Creating test jobs ...')
    configxml = 'master-job-svn-config.xml'
    configxml = open(configxml).read().encode('utf8')
    webapi.job_create('master-job-svn', configxml)
    return webapi
开发者ID:PaulKlumpp,项目名称:jenkins-autojobs,代码行数:15,代码来源:test_svn.py

示例2: JenkinsControl

# 需要导入模块: from jenkins import Jenkins [as 别名]
# 或者: from jenkins.Jenkins import job_create [as 别名]
class JenkinsControl(object):
    war = pjoin(here, "tmp/jenkins.war")
    cli = pjoin(here, "tmp/jenkins-cli.jar")
    home = pjoin(here, "tmp/jenkins")

    def __init__(self, addr="127.0.0.1:60888", cport="60887"):
        self.addr, self.port = addr.split(":")
        self.url = "http://%s" % addr
        self.py = Jenkins(self.url)

    def start_server(self):
        cmd = pjoin(here, "./bin/start-jenkins.sh 1>/dev/null 2>&1")
        env = {
            "JENKINS_HOME": self.home,
            "JENKINS_PORT": self.port,
            "JENKINS_CPORT": self.cport,
            "JENKINS_ADDR": self.addr,
        }
        check_call(cmd, shell=True, env=env)

    def shutdown_server(self):
        cmd = "echo 0 | nc %s %s" % (self.addr, self.cport)
        check_call(cmd, shell=True)

    def clean_home(self):
        rmtree(self.home)

    def createjob(self, name, configxml_fn):
        configxml = open(configxml_fn).read().encode("utf8")
        self.py.job_create(name, configxml)

    def getjobs(self):
        return {i.name: i for i in self.py.jobs}

    def enabled(self, name):
        return self.py.job(name).info["buildable"]

    def job_etree(self, job):
        res = self.py.job(job).config
        res = etree.fromstring(res)
        return res
开发者ID:Recras,项目名称:jenkins-autojobs,代码行数:43,代码来源:util.py

示例3: JenkinsControl

# 需要导入模块: from jenkins import Jenkins [as 别名]
# 或者: from jenkins.Jenkins import job_create [as 别名]
class JenkinsControl(object):
    war = pjoin(here, 'tmp/jenkins.war')
    cli = pjoin(here, 'tmp/jenkins-cli.jar')
    home = pjoin(here, 'tmp/jenkins')

    def __init__(self, addr='127.0.0.1:60888', cport='60887'):
        self.addr, self.port = addr.split(':')
        self.url = 'http://%s' % addr
        self.py = Jenkins(self.url)

    def start_server(self):
        cmd = pjoin(here, './bin/start-jenkins.sh 1>/dev/null 2>&1')
        env = {'JENKINS_HOME':  self.home,
               'JENKINS_PORT':  self.port,
               'JENKINS_CPORT': self.cport,
               'JENKINS_ADDR':  self.addr}
        check_call(cmd, shell=True, env=env)

    def shutdown_server(self):
        cmd = 'echo 0 | nc %s %s' % (self.addr, self.cport)
        check_call(cmd, shell=True)

    def clean_home(self):
        rmtree(self.home)

    def createjob(self, name, configxml_fn):
        configxml = open(configxml_fn).read().encode('utf8')
        self.py.job_create(name, configxml)

    def getjobs(self):
        return {i.name: i for i in self.py.jobs}

    def enabled(self, name):
        return self.py.job(name).info['buildable']

    def job_etree(self, job):
        res = self.py.job(job).config
        res = etree.fromstring(res)
        return res
开发者ID:ThomasMatern,项目名称:jenkins-autojobs,代码行数:41,代码来源:util.py

示例4: Jenkins

# 需要导入模块: from jenkins import Jenkins [as 别名]
# 或者: from jenkins.Jenkins import job_create [as 别名]
import os
import settings
from jenkins import Jenkins, JenkinsError

# get a handle for the jenkins server
j = Jenkins(os.environ['ENDPOINT'], os.environ['USERNAME'], os.environ['PASSWORD'])

# open the config.xml
with open("./xml/folders/base/config.xml") as config_file:
    config = config_file.read()

for team in settings.teams:
    if j.job_exists(team):
        print("\tFolder exists; skipping: %s" % team)
    else:
        try:
            print("\tCreating folder: %s" % team)
            j.job_create(team, config)
        except JenkinsError as e:
            print("\tERROR: %s" % e)
开发者ID:managedkaos,项目名称:create-jenkins-jobs,代码行数:22,代码来源:folders.py


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