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


Python jenkins.Jenkins类代码示例

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


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

示例1: main

def main(argv):
    parser = OptionParser(version=VERSION)

    parser.add_option("-c", "--create-job", dest="create_job",
                      help="Task to create a new job",
                      action="store_true")

    parser.add_option("-j", "--job-name", dest="job_name",
                      help="Job's name",
                      metavar="CREATE")

    parser.add_option("-f", "--file", dest="filename",
                      help="Path do jenkins config file",
                      metavar="FILE")

    parser.add_option("-u", "--url", dest="url",
                      help="Jenkins server URL",
                      metavar="FILE")

    options, _ = parser.parse_args()

    validate(options)

    ci = Jenkins(url=options.url)

    config = ""
    with open(options.filename, "r") as config_file:
        config = config_file.read()

    config_file.close()

    job_name = options.job_name

    if options.create_job:
        ci.create_job(job_name, config)
开发者ID:victorpantoja,项目名称:python-jenkins,代码行数:35,代码来源:python_jenkins.py

示例2: main

def main(build_url, sleeptime=15, pushover=False):
    if pushover and not have_pushover:
        raise SystemExit("ERROR: to use pushover notifications, please `pip install python-pushover` and configure it.")
    job_name, build_no = get_job_name_and_build_number(build_url)
    jenkins_url = get_jenkins_base_url(build_url)
    logger.debug("Connecting to Jenkins...")
    """
    NOTE: this is using unauthenticated / anonymous access.
    If that doesn't work for you, change this to something like:
    j = Jenkins(jenkins_url, 'username', 'password')
    """
    j = Jenkins(jenkins_url)
    logger.debug("Connected.")
    if build_no is None:
        jobinfo = j.get_job_info(job_name)
        build_no = jobinfo['nextBuildNumber'] - 1
        print("Using latest build, #{b}".format(b=build_no))
    build_url = get_formal_build_url(jenkins_url, job_name, build_no)
    print("Watching job {j} #{b} until completion <{u}>...".format(j=job_name, b=build_no, u=build_url))
    while True:
        buildinfo = j.get_build_info(job_name, build_no)
        if not buildinfo['building']:
            # job is not still building
            duration = datetime.timedelta(seconds=(buildinfo['duration'] / 1000))
            if pushover:
                notify_pushover(buildinfo['result'], job_name, build_no, duration, build_url)
            if buildinfo['result'] == "SUCCESS":
                print("SUCCESS for {j} #{b} in {d} <{bu}>".format(j=job_name, b=build_no, bu=build_url, d=duration))
                raise SystemExit(0)
            print("{r}: {j} #{b} failed in {d}".format(j=job_name, b=build_no, r=buildinfo['result'], d=duration))
            raise SystemExit(1)
        else:
            duration = datetime.datetime.now() - datetime.datetime.fromtimestamp(buildinfo['timestamp'] / 1000)
            print("still running ({d})...".format(d=duration))
        time.sleep(sleeptime)
开发者ID:m0nkey,项目名称:misc-scripts,代码行数:35,代码来源:watch_jenkins.py

示例3: build_jobs

def build_jobs(credentials, test_plans, args):
    jenkins = Jenkins('http://juju-ci.vapour.ws:8080', *credentials)
    for test_plan in test_plans:
        test_id = generate_test_id()
        for controller in args.controllers:
            job_name = get_job_name(controller)
            parameter = make_parameters(test_plan, args, controller, test_id)
            jenkins.build_job(job_name, parameter, token=args.cwr_test_token)
开发者ID:chuckbutler,项目名称:build-cloud,代码行数:8,代码来源:schedule_cwr_jobs.py

示例4: config_jenkins

    def config_jenkins(self, jenkins_url, jenkins_config_file, job_name):
        ci = Jenkins(url=jenkins_url)

        config = ""
        with open(jenkins_config_file, "r") as config_file:
            config = config_file.read()

        config_file.close()
        ci.create_job(job_name, config)
开发者ID:victorpantoja,项目名称:git-repo-manager,代码行数:9,代码来源:classes.py

示例5: deleteJobs

 def deleteJobs(self):
     j=Jenkins('http://jenkins-ccp.citrix.com','talluri','vmops.com')
     for i in range(757,918):
        print "deleting job %s"%("report_generator_"+str(i)+"_zone-xen_XenServer.xml")
        try:
           j.delete_job("report_generator_"+str(i)+"_zone-xen_XenServer.xml")
        except Exception,e:
            print e
            pass     
开发者ID:swill,项目名称:cloudstack-automation,代码行数:9,代码来源:jenkinsJob.py

示例6: reportUsingJenkinsEmailPlugin

    def reportUsingJenkinsEmailPlugin(self, marvinConfigJson, env, execOnOneZone = True):
        try:
            jobIdentifierList = []
            bugLoggerData = []
            j = Jenkins('http://jenkins-ccp.citrix.com', 'bharatk', 'BharatK')
            for zone in cscfg.zones:
                self.logger.info(zone.name)
                for pod in zone.pods:
                    for cluster in pod.clusters:
                        self.logger.info('creating a jeknins job to generate results and email notfication for hypervisor %s and zone %s' % (cluster.hypervisor, zone.name))
                        modifiedjob = jobModifier.modifyReportGenerator(env['build_number'] + '_' + zone.name + '_' + cluster.hypervisor, mailto)
                        jobname = modifiedjob
                        file = open('/root/cloud-autodeploy2/newcode/' + modifiedjob, 'r')
                        config = file.read()
                        file.close()
                        j.create_job(modifiedjob, config)
                        j.build_job(modifiedjob, {'buildNumber': env['build_number'],
                         'BuildNo': env['build_number'],
                         'MGMT_SVR': env['hostip'],
                         'BASEDIR': env['virtenvPath'],
                         'version': env['version'],
                         'BranchInfo': env['version'],
                         'GitRepoUrl': env['repo_url'],
                         'GitCommitId': env['commit_id'],
                         'CIRunStartDateTime': env['startTime'],
                         'CIRunEndDateTime': time.strftime('%c'),
                         'WikiLinks': 'https://cwiki.apache.org/confluence/display/CLOUDSTACK/Infrastructure%2CCI%2CSimulator%2CAutomation+Changes',
                         'hypervisor': cluster.hypervisor.lower(),
                         'HyperVisorInfo': cluster.hypervisor.lower(),
                         'zoneName': zone.name,
                         'BuildReport': 'https://www.dropbox.com/sh/yj3wnzbceo9uef2/AAB6u-Iap-xztdm6jHX9SjPja?dl=0',
                         'token': 'bharat'})
                        jobIdentifierList.append('report_' + zone.name)
                        jobDetails = {'job_name': modifiedjob,
                         'related_data_path': env['virtenvPath']}
                        self.resourceMgr.addJobDetails(jobDetails)
                        bugLoggerData.append({'hypervisor': cluster.hypervisor.lower(),
                         'branch': env['version'],
                         'logname': cluster.hypervisor.lower() + '__Log_' + env['build_number'],
                         'type': 'BVT'})
                        self.logger.info('bug logger data in zone looop %s' % bugLoggerData)
                        self.waitForJobComplete(env['virtenvPath'], jobIdentifierList)
                        self.archiveTestRunLogs(env, cluster.hypervisor.lower(), jobname)
                        break

                    break

                if execOnOneZone:
                    break
                self.logger.info('job identifier list %s' % jobIdentifierList)
                self.logger.info('cleaning up the workspace')
                bash('rm -f /root/cloud-autodeploy2/newcode/%s' % modifiedjob)
                self.logger.info('running bug logger')

        except Exception as e:
            self.logger.exception(e)
开发者ID:bvbharatk,项目名称:cloudstack-automation,代码行数:56,代码来源:testEnv.py

示例7: build_job

def build_job(credentials, root, job_name, candidates, suite):
    parameters = {'suite': ','.join(suite), 'attempts': '10'}
    jenkins = Jenkins('http://juju-ci.vapour.ws:8080', credentials.user,
                      credentials.password)
    for candidate, revision_build in candidates:
        call_parameters = {
            'revision_build': '{:d}'.format(revision_build),
            }
        call_parameters.update(parameters)
        jenkins.build_job(job_name, call_parameters)
开发者ID:mjs,项目名称:juju,代码行数:10,代码来源:schedule_reliability_tests.py

示例8: __init__

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)
开发者ID:NALSS,项目名称:BranchBuilder,代码行数:25,代码来源:buildutil.py

示例9: get_job_name

def get_job_name(adaptation_release):
  tmp = 'adaptations_trunk_' + adaptation_release +'_ris'
  jenkins = Jenkins_Url(URL,USER,PASS)
  if jenkins.job_exists(tmp):
    return tmp
  tmp = 'adaptation_trunk_' + adaptation_release +'_ris'
  if jenkins.job_exists(tmp):
    return tmp
  print "Jenkins doesn't exist: " + tmp
  log("FAILED"," jenkins name dosen't exits " + tmp)
  return 0
开发者ID:Maginx,项目名称:git_home,代码行数:11,代码来源:get_jenkins_names.py

示例10: create_jenkins_job

def create_jenkins_job(init_job_config, job_name):
    """
    Create new job by getting config file 
    from existing job
    """

    j = Jenkins("http://localhost:8080")

    str_config = j.get_job_config(init_job_config)

    if j.job_exists(job_name) == False:
        j.create_job(job_name, str_config)
开发者ID:Adilla,项目名称:oudjat,代码行数:12,代码来源:auto_jenkins.py

示例11: build_jobs

def build_jobs(credentials, test_plans, args):
    jenkins = Jenkins('http://juju-ci.vapour.ws:8080', *credentials)
    for test_plan in test_plans:
        test_id = generate_test_id()
        test_plan_content = load_test_plan(test_plan)
        test_label = test_plan_content.get('test_label')
        if test_label and isinstance(test_label, str):
            test_label = [test_label]
        for controller in test_label or args.controllers:
            job_name = get_job_name(controller)
            parameter = make_parameters(test_plan, controller, test_id)
            jenkins.build_job(job_name, parameter, token=args.cwr_test_token)
开发者ID:seman,项目名称:build-cloud,代码行数:12,代码来源:schedule_cwr_jobs.py

示例12: jenkins

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,代码行数:13,代码来源:test_svn.py

示例13: get_plugins_dict

def get_plugins_dict(jenkins_url, puppet=False, user=None, password=None):
    if user is not None:
        logger.debug("Connecting to Jenkins (<%s>) as user %s ...",
                     jenkins_url, user)
        j = Jenkins(jenkins_url, user, password)
    else:
        logger.debug("Connecting to Jenkins (<%s>) anonymously...", jenkins_url)
        j = Jenkins(jenkins_url)
    logger.debug("Connected.")
    p = j.get_plugins()
    plugins = {}
    for k, v in p.items():
        plugins[k[0]] = v['version']
    return plugins
开发者ID:jantman,项目名称:misc-scripts,代码行数:14,代码来源:jenkins_list_plugins.py

示例14: run

    def run(self):
        # Run the egg_info step to find our VCS url.
        self.run_command('egg_info')
        if not self.distribution.metadata.url:
            log.warn("This package does not appear to be in any repository, "
                     "aborting.")
            sys.exit(1)

        # Pull down Jenkins package
        base.fetch_build_eggs(['python-jenkins'], dist=self.distribution)
        from jenkins import Jenkins
        server = CONFIG.jenkins_url
        log.info("Connecting to Jenkins at %s" % server)

        jenkins = Jenkins(server, self.username, self.password)
        name = self.distribution.metadata.name

        if (self.matrix):
            log.info("Matrix job")
            if CONFIG.jenkins_matrix_job_xml:
                path, fname = CONFIG.jenkins_matrix_job.split(':')
            else:
                path, fname = None, 'jenkins_job_matrix.xml'
        else:
            log.info("Non-matrix job - use \'--matrix\' option for matrix builds")
            if CONFIG.jenkins_job_xml:
                path, fname = CONFIG.jenkins_job.split(':')
            else:
                path, fname = None, 'jenkins_job.xml'

        with open(base.get_resource_file(fname, path)) as f:
            jenkins_config_xml = Template(f.read())

        cfg_xml = jenkins_config_xml.safe_substitute(
            name=cgi.escape(name),
            hyphen_escaped_name=cgi.escape(name).replace("-", "?").replace("_", "?"),
            description=cgi.escape(self.distribution.metadata.description),
            repository=self.distribution.metadata.url,
            email=self.distribution.metadata.author_email,
            python_string_xml=self._construct_string_values(self._get_active_python_versions()),
            virtualenv=CONFIG.virtualenv_executable,
            username=self.username
        )

        if jenkins.job_exists(name):
            log.error("Job found at %s/job/%s Please delete this before creating a new one." % (server, name))
        else:
            if (not self.dry_run):
                log.info("Creating job at %s/job/%s" % (server, name))
                jenkins.create_job(name, cfg_xml)
开发者ID:agiledata,项目名称:pkglib,代码行数:50,代码来源:jenkins_.py

示例15: restartJenkins

 def restartJenkins(self):
     self.checkForSuccess(bash("service jenkins restart"))
     retry=20
     while retry > 0:
       retry-=1
       try:
           j=Jenkins(self.jenkinsUrl, "admin", self.jenkinsPasswd)
           j.get_plugins()
           break
       except Exception as e:
            if retry==0:
               self.logger.info("Failed to restart jenkins")  
            else:
               time.sleep(20)
               self.logger.info("waiting for jenkins to restart, this may take a while")
开发者ID:bvbharatk,项目名称:CI-orchestrator,代码行数:15,代码来源:configure_jenkins.py


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