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


Python jenkins.Jenkins方法代码示例

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


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

示例1: test_jenkins_jobs

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def test_jenkins_jobs():
    master = Jenkins('http://127.0.0.1:8080')
    test_job = master.get_job_info('test_job')

    assert test_job['name'] == 'test_job'
    assert test_job['buildable'] 
开发者ID:emmetog,项目名称:ansible-jenkins,代码行数:8,代码来源:test_default.py

示例2: get_queue_item

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def get_queue_item(self, queue_id):
        """Attempt to retrieve Jenkins job queue item.

        Exception communicating queue doesn't exist is expected,
        in that case method returns empty dict.

            :param queue_id:            Jenkins job queue ID number
            :type queue_id:             int
            :return:                    Dictionary representing Jenkins job queue item
            :rtype:                     dict
        """
        try:
            return self.jenkins.get_queue_item(queue_id)
        except Exception as e:
            # Exception 'queue does not exist' is expected behaviour when job is running
            if 'queue' in str(e) and 'does not exist' in str(e):
                return {}
            else:
                raise 
开发者ID:NervanaSystems,项目名称:ngraph-onnx,代码行数:21,代码来源:JenkinsWrapper.py

示例3: get_idle_ci_hosts

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def get_idle_ci_hosts(self):
        """Query Jenkins for idle servers.

        Send GET request to Jenkins server, querying for idle servers labeled
        for nGraph-ONNX CI job.

            :return:     Number of idle hosts delegated to nGraph-ONNX CI
            :rtype:      int
        """
        jenkins_request_url = self.jenkins_server + 'label/ci&&onnx/api/json?pretty=true'
        try:
            log.info('Sending request to Jenkins: %s', jenkins_request_url)
            r = requests.Request(method='GET', url=jenkins_request_url, verify=False)
            response = self.jenkins.jenkins_request(r).json()
            return int(response['totalExecutors']) - int(response['busyExecutors'])
        except Exception as e:
            log.exception('Failed to send request to Jenkins!\nException message: %s', str(e))
            raise 
开发者ID:NervanaSystems,项目名称:ngraph-onnx,代码行数:20,代码来源:JenkinsWrapper.py

示例4: test_build_job_request_settings

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def test_build_job_request_settings(self):
        jenkins_mock = mock.Mock(spec=jenkins.Jenkins, auth='secret', timeout=2)
        jenkins_mock.build_job_url.return_value = 'http://apache.org'

        with mock.patch(
            'airflow.providers.jenkins.operators.jenkins_job_trigger.jenkins_request_with_headers'
        ) as mock_make_request:
            operator = JenkinsJobTriggerOperator(
                dag=None,
                task_id="build_job_test",
                job_name="a_job_on_jenkins",
                jenkins_connection_id="fake_jenkins_connection")
            operator.build_job(jenkins_mock)
            mock_request = mock_make_request.call_args_list[0][0][1]

        self.assertEqual(mock_request.method, 'POST')
        self.assertEqual(mock_request.url, 'http://apache.org') 
开发者ID:apache,项目名称:airflow,代码行数:19,代码来源:test_jenkins_job_trigger.py

示例5: deprovision

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def deprovision(self, **kwargs):
        """
        Deprovisioning isn't supported for Jenkins provisioner yet.

        Implementation of :func:`~kqueen.engines.base.BaseEngine.deprovision`
        """
        ctx = config.get('JENKINS_DEPROVISION_JOB_CTX')
        cluster_name = self.job_parameter_map['cluster_name']
        ctx[cluster_name] = 'kqueen-{}'.format(self.cluster.id)
        try:
            self.client.build_job(self.deprovision_job_name, ctx)
            return True, None
        except Exception as e:
            msg = 'Creating cluster {} failed with following reason:'.format(self.cluster.id)
            logger.exception(msg)
            return False, msg
        return None, None 
开发者ID:Mirantis,项目名称:kqueen,代码行数:19,代码来源:jenkins.py

示例6: _get_build_number

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def _get_build_number(self):
        """
        Get external ID of cluster, in this case Jenkins job ID.

        First we try to get build_number from related object metadata, if there is no build_number
        yet, we need to look it up in build history of our configured provisioning Jenkins job

        Returns:
            int: Jenkins job ID
        """
        metadata = self.cluster.metadata or {}
        build_number = metadata.get('build_number', None)
        if build_number:
            return build_number
        try:
            cluster = self._get_by_id()
            build_number = cluster['metadata']['build_number']
            self._save_cluster_metadata(build_number)
            return build_number
        except Exception:
            pass
        return build_number 
开发者ID:Mirantis,项目名称:kqueen,代码行数:24,代码来源:jenkins.py

示例7: engine_status

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def engine_status(cls, **kwargs):
        """
        Implementation of :func:`~kqueen.engines.base.BaseEngine.engine_status`
        """
        conn_kw = {
            'username': kwargs.get('username', config.get('JENKINS_USERNAME')),
            'password': kwargs.get('password', config.get('JENKINS_PASSWORD')),
            'timeout': 10
        }
        status = config.get('PROVISIONER_UNKNOWN_STATE')
        try:
            client = jenkins.Jenkins(config.get('JENKINS_API_URL'), **conn_kw)
            auth_verify = client.get_whoami()
            if auth_verify:
                status = config.get('PROVISIONER_OK_STATE')
        except Exception as e:
            logger.exception('Could not contact JenkinsEngine backend: ')
            status = config.get('PROVISIONER_ERROR_STATE')
        return status 
开发者ID:Mirantis,项目名称:kqueen,代码行数:21,代码来源:jenkins.py

示例8: test_jenkins_version

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def test_jenkins_version():
    master = Jenkins('http://127.0.0.1:8080')
    version = master.get_version()

    assert version == '2.176.1' 
开发者ID:emmetog,项目名称:ansible-jenkins,代码行数:7,代码来源:test_default.py

示例9: test_jenkins_plugins

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def test_jenkins_plugins():
    master = Jenkins('http://127.0.0.1:8080')
    plugins = master.get_plugins()

    assert plugins['git']['active']
    assert plugins['git']['enabled'] 
开发者ID:emmetog,项目名称:ansible-jenkins,代码行数:8,代码来源:test_default.py

示例10: test_jenkins_version

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def test_jenkins_version():
    master = Jenkins('http://127.0.0.1:8080')
    version = master.get_version()

    assert version == '2.190.1' 
开发者ID:emmetog,项目名称:ansible-jenkins,代码行数:7,代码来源:test_default.py

示例11: test_jenkins_version

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def test_jenkins_version():
    master = Jenkins('https://127.0.0.1:8080')
    version = master.get_version()

    assert version == '2.190.2' 
开发者ID:emmetog,项目名称:ansible-jenkins,代码行数:7,代码来源:test_default.py

示例12: trigger_jenkins_build

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def trigger_jenkins_build(
    project_path,
    url,
    job,
    token,
    branch,
    branch_to,
    cause,
    ci_username=None,
    ci_password=None,
):
    """ Trigger a build on a jenkins instance."""
    try:
        import jenkins
    except ImportError:
        _log.error("Pagure-CI: Failed to load the jenkins module, bailing")
        return

    _log.info("Jenkins CI")

    repo = "%s/%s" % (pagure_config["GIT_URL_GIT"].rstrip("/"), project_path)

    data = {
        "cause": cause,
        "REPO": repo,
        "BRANCH": branch,
        "BRANCH_TO": branch_to,
    }

    server = jenkins.Jenkins(
        url, username=ci_username or None, password=ci_password or None
    )
    _log.info(
        "Pagure-CI: Triggering at: %s for: %s - data: %s", url, job, data
    )
    try:
        server.build_job(name=job, parameters=data, token=token)
        _log.info("Pagure-CI: Build triggered")
    except Exception as err:
        _log.info("Pagure-CI:An error occured: %s", err) 
开发者ID:Pagure,项目名称:pagure,代码行数:42,代码来源:lib_ci.py

示例13: connect

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def connect(self, params={}):
        username = params.get('credentials').get('username')
        password = params.get('credentials').get('password')
        host = params.get('host')

        self.logger.info("Connect: Connecting...")

        self.server = jenkins.Jenkins(host, username=username, password=password) 
开发者ID:rapid7,项目名称:insightconnect-plugins,代码行数:10,代码来源:connection.py

示例14: test

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def test(self):
        try:
            self.server.get_whoami()
        except EmptyResponseException as e:
            raise ConnectionTestException(cause="An empty response was received while attempting to connect to Jenkins.",
                                          assistance="Double-check your Jenkins server configuration.",
                                          data=e)
        except BadHTTPException as e:
            raise ConnectionTestException(
                cause="A bad HTTP response was received while attempting to connect to Jenkins.",
                assistance="Double-check your Jenkins server configuration and ensure it is reachable.",
                data=e)

        return {"success": True} 
开发者ID:rapid7,项目名称:insightconnect-plugins,代码行数:16,代码来源:connection.py

示例15: __init__

# 需要导入模块: import jenkins [as 别名]
# 或者: from jenkins import Jenkins [as 别名]
def __init__(self):
        self.jenkins_password=jenkins_password
        self.jenkins_user=jenkins_user
        self.jenkins_url=jenkins_url
        try:
            self.servir=jenkins.Jenkins(url=self.jenkins_url,username=self.jenkins_user,
                                        password=self.jenkins_password,timeout=20)
        except Exception as e:
            print('Jenkins 链接失败!原因:%s'%e) 
开发者ID:liwanlei,项目名称:FXTest,代码行数:11,代码来源:CollectionJenkins.py


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