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


Python config.JJBConfig类代码示例

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


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

示例1: TestCaseTestJenkinsManager

class TestCaseTestJenkinsManager(base.BaseTestCase):
    def setUp(self):
        super(TestCaseTestJenkinsManager, self).setUp()
        self.jjb_config = JJBConfig()
        self.jjb_config.validate()

    def test_plugins_list(self):
        self.jjb_config.builder['plugins_info'] = ['plugin1', 'plugin2']
        self.builder = jenkins_jobs.builder.JenkinsManager(self.jjb_config)
        self.assertEqual(self.builder.plugins_list, ['plugin1', 'plugin2'])

    @mock.patch.object(jenkins_jobs.builder.jenkins.Jenkins,
                       'get_plugins_info', return_value=['p1', 'p2'])
    def test_plugins_list_from_jenkins(self, jenkins_mock):
        # Trigger fetching the plugins from jenkins when accessing the property
        self.jjb_config.builder['plugins_info'] = None
        self.builder = jenkins_jobs.builder.JenkinsManager(self.jjb_config)
        self.assertEqual(self.builder.plugins_list, ['p1', 'p2'])

    def test_delete_managed(self):
        self.jjb_config.builder['plugins_info'] = []
        self.builder = jenkins_jobs.builder.JenkinsManager(self.jjb_config)

        with mock.patch.multiple('jenkins_jobs.builder.JenkinsManager',
                                 get_jobs=mock.DEFAULT,
                                 is_managed=mock.DEFAULT,
                                 delete_job=mock.DEFAULT) as patches:
            patches['get_jobs'].return_value = [{'name': 'job1'},
                                                {'name': 'job2'}]
            patches['is_managed'].side_effect = [True, True]

            self.builder.delete_old_managed()
            self.assertEquals(patches['delete_job'].call_count, 2)
开发者ID:mnarusze,项目名称:jenkins-job-builder,代码行数:33,代码来源:test_manager.py

示例2: TestCaseTestJenkinsManager

class TestCaseTestJenkinsManager(base.BaseTestCase):

    def setUp(self):
        super(TestCaseTestJenkinsManager, self).setUp()
        self.jjb_config = JJBConfig()
        self.jjb_config.validate()

    def test_plugins_list(self):
        self.jjb_config.builder['plugins_info'] = _plugins_info

        self.builder = jenkins_jobs.builder.JenkinsManager(self.jjb_config)
        self.assertEqual(self.builder.plugins_list, _plugins_info)

    @mock.patch.object(jenkins_jobs.builder.jenkins.Jenkins,
                       'get_plugins',
                       return_value=_plugins_info)
    def test_plugins_list_from_jenkins(self, jenkins_mock):
        # Trigger fetching the plugins from jenkins when accessing the property
        self.jjb_config.builder['plugins_info'] = {}
        self.builder = jenkins_jobs.builder.JenkinsManager(self.jjb_config)
        # See https://github.com/formiaczek/multi_key_dict/issues/17
        # self.assertEqual(self.builder.plugins_list, k)
        for key_tuple in self.builder.plugins_list.keys():
            for key in key_tuple:
                self.assertEqual(self.builder.plugins_list[key],
                                 _plugins_info[key])

    def test_delete_managed(self):
        self.jjb_config.builder['plugins_info'] = {}
        self.builder = jenkins_jobs.builder.JenkinsManager(self.jjb_config)

        with mock.patch.multiple('jenkins_jobs.builder.JenkinsManager',
                                 get_jobs=mock.DEFAULT,
                                 is_job=mock.DEFAULT,
                                 is_managed=mock.DEFAULT,
                                 delete_job=mock.DEFAULT) as patches:
            patches['get_jobs'].return_value = [{'fullname': 'job1'},
                                                {'fullname': 'job2'}]
            patches['is_managed'].side_effect = [True, True]
            patches['is_job'].side_effect = [True, True]

            self.builder.delete_old_managed()
            self.assertEqual(patches['delete_job'].call_count, 2)

    def _get_plugins_info_error_test(self, error_string):
        builder = jenkins_jobs.builder.JenkinsManager(self.jjb_config)
        exception = jenkins_jobs.builder.jenkins.JenkinsException(error_string)
        with mock.patch.object(builder.jenkins, 'get_plugins',
                               side_effect=exception):
            plugins_info = builder.get_plugins_info()
        self.assertEqual([_plugins_info['plugin1']], plugins_info)

    def test_get_plugins_info_handles_connectionrefused_errors(self):
        self._get_plugins_info_error_test('Connection refused')

    def test_get_plugins_info_handles_forbidden_errors(self):
        self._get_plugins_info_error_test('Forbidden')
开发者ID:cezidev,项目名称:jenkins-job-builder,代码行数:57,代码来源:test_manager.py

示例3: setUp

    def setUp(self):
        super(ModuleRegistryPluginInfoTestsWithScenarios, self).setUp()

        jjb_config = JJBConfig()
        jjb_config.validate()

        plugin_info = [{"shortName": "HerpDerpPlugin", "longName": "Blah Blah Blah Plugin"}]
        plugin_info.append({"shortName": "JankyPlugin1", "longName": "Not A Real Plugin", "version": self.v1})

        self.addDetail("plugin_info", text_content(str(plugin_info)))
        self.registry = ModuleRegistry(jjb_config, plugin_info)
开发者ID:asdwsda,项目名称:jenkins-job-builder,代码行数:11,代码来源:test_moduleregistry.py

示例4: test_retain_anchors_enabled

    def test_retain_anchors_enabled(self):
        """
        Verify that anchors are retained across files if retain_anchors is
        enabled in the config.
        """

        files = ["custom_retain_anchors_include001.yaml",
                 "custom_retain_anchors.yaml"]

        jjb_config = JJBConfig()
        jjb_config.yamlparser['retain_anchors'] = True
        jjb_config.validate()
        j = YamlParser(jjb_config)
        j.load_files([os.path.join(self.fixtures_path, f) for f in files])
开发者ID:openstack-infra,项目名称:jenkins-job-builder,代码行数:14,代码来源:test_localyaml.py

示例5: test_retain_anchors_default

    def test_retain_anchors_default(self):
        """
        Verify that anchors are NOT retained across files by default.
        """

        files = ["custom_retain_anchors_include001.yaml",
                 "custom_retain_anchors.yaml"]

        jjb_config = JJBConfig()
        # use the default value for retain_anchors
        jjb_config.validate()
        j = YamlParser(jjb_config)
        with ExpectedException(yaml.composer.ComposerError,
                               "found undefined alias.*"):
            j.load_files([os.path.join(self.fixtures_path, f) for f in files])
开发者ID:openstack-infra,项目名称:jenkins-job-builder,代码行数:15,代码来源:test_localyaml.py

示例6: TestCaseTestBuilder

class TestCaseTestBuilder(base.BaseTestCase):
    def setUp(self):
        super(TestCaseTestBuilder, self).setUp()
        self.jjb_config = JJBConfig()
        self.jjb_config.validate()

    def test_plugins_list(self):
        self.jjb_config.builder['plugins_info'] = ['plugin1', 'plugin2']
        self.builder = jenkins_jobs.builder.JenkinsManager(self.jjb_config)
        self.assertEqual(self.builder.plugins_list, ['plugin1', 'plugin2'])

    @mock.patch.object(jenkins_jobs.builder.jenkins.Jenkins,
                       'get_plugins_info', return_value=['p1', 'p2'])
    def test_plugins_list_from_jenkins(self, jenkins_mock):
        # Trigger fetching the plugins from jenkins when accessing the property
        self.jjb_config.builder['plugins_info'] = None
        self.builder = jenkins_jobs.builder.JenkinsManager(self.jjb_config)
        self.assertEqual(self.builder.plugins_list, ['p1', 'p2'])
开发者ID:akulakhan,项目名称:jenkins-job-builder,代码行数:18,代码来源:test_builder.py

示例7: __init__

    def __init__(self, args=None, **kwargs):
        if args is None:
            args = []
        self.parser = create_parser()
        self.options = self.parser.parse_args(args)

        self.jjb_config = JJBConfig(self.options.conf, **kwargs)

        if not self.options.command:
            self.parser.error("Must specify a 'command' to be performed")

        if (self.options.log_level is not None):
            self.options.log_level = getattr(logging,
                                             self.options.log_level.upper(),
                                             logger.getEffectiveLevel())
            logger.setLevel(self.options.log_level)

        self._parse_additional()
        self.jjb_config.validate()
开发者ID:tamac-io,项目名称:jenkins-job-builder,代码行数:19,代码来源:entry.py

示例8: test_multiple_same_anchor_in_multiple_toplevel_yaml

    def test_multiple_same_anchor_in_multiple_toplevel_yaml(self):
        """
        Verify that anchors/aliases only span use of '!include' tag

        To ensure that any yaml loaded by the include tag is in the same
        space as the top level file, but individual top level yaml definitions
        are treated by the yaml loader as independent.
        """

        files = ["custom_same_anchor-001-part1.yaml",
                 "custom_same_anchor-001-part2.yaml"]

        jjb_config = JJBConfig()
        jjb_config.jenkins['url'] = 'http://example.com'
        jjb_config.jenkins['user'] = 'jenkins'
        jjb_config.jenkins['password'] = 'password'
        jjb_config.builder['plugins_info'] = []
        jjb_config.validate()
        j = YamlParser(jjb_config)
        j.load_files([os.path.join(self.fixtures_path, f) for f in files])
开发者ID:Ladicle,项目名称:jenkins-job-builder,代码行数:20,代码来源:test_localyaml.py

示例9: setUp

 def setUp(self):
     super(TestCaseTestBuilder, self).setUp()
     self.jjb_config = JJBConfig()
     self.jjb_config.validate()
开发者ID:akulakhan,项目名称:jenkins-job-builder,代码行数:4,代码来源:test_builder.py

示例10: _get_config

    def _get_config(self):
        jjb_config = JJBConfig(self.conf_filename)
        jjb_config.validate()

        return jjb_config
开发者ID:asdwsda,项目名称:jenkins-job-builder,代码行数:5,代码来源:base.py

示例11: JenkinsJobs

class JenkinsJobs(object):
    """ This is the entry point class for the `jenkins-jobs` command line tool.
    While this class can be used programmatically by external users of the JJB
    API, the main goal here is to abstract the `jenkins_jobs` tool in a way
    that prevents test suites from caring overly much about various
    implementation details--for example, tests of subcommands must not have
    access to directly modify configuration objects, instead they must provide
    a fixture in the form of an .ini file that provides the configuration
    necessary for testing.

    External users of the JJB API may be interested in this class as an
    alternative to wrapping `jenkins_jobs` with a subprocess that execs it as a
    system command; instead, python scripts may be written that pass
    `jenkins_jobs` args directly to this class to allow programmatic setting of
    various command line parameters.
    """

    def __init__(self, args=None, **kwargs):
        if args is None:
            args = []
        self.parser = create_parser()
        self.options = self.parser.parse_args(args)

        self.jjb_config = JJBConfig(self.options.conf,
                                    config_section=self.options.section,
                                    **kwargs)

        if not self.options.command:
            self.parser.error("Must specify a 'command' to be performed")

        if (self.options.log_level is not None):
            self.options.log_level = getattr(logging,
                                             self.options.log_level.upper(),
                                             logger.getEffectiveLevel())
            logger.setLevel(self.options.log_level)

        self._parse_additional()
        self.jjb_config.validate()

    def _set_config(self, target, option):
        """
        Sets the option in target only if the given option was explicitly set
        """
        opt_val = getattr(self.options, option, None)
        if opt_val is not None:
            target[option] = opt_val

    def _parse_additional(self):

        self._set_config(self.jjb_config.builder, 'ignore_cache')
        self._set_config(self.jjb_config.builder, 'flush_cache')
        self._set_config(self.jjb_config.yamlparser, 'allow_empty_variables')
        self._set_config(self.jjb_config.jenkins, 'section')
        self._set_config(self.jjb_config.jenkins, 'user')
        self._set_config(self.jjb_config.jenkins, 'password')

        if getattr(self.options, 'plugins_info_path', None) is not None:
            with io.open(self.options.plugins_info_path, 'r',
                         encoding='utf-8') as yaml_file:
                plugins_info = yaml.load(yaml_file)
            if not isinstance(plugins_info, list):
                self.parser.error("{0} must contain a Yaml list!".format(
                                  self.options.plugins_info_path))
            self.jjb_config.builder['plugins_info'] = plugins_info

        if getattr(self.options, 'path', None):
            if hasattr(self.options.path, 'read'):
                logger.debug("Input file is stdin")
                if self.options.path.isatty():
                    if platform.system() == 'Windows':
                        key = 'CTRL+Z'
                    else:
                        key = 'CTRL+D'
                    logger.warning("Reading configuration from STDIN. "
                                   "Press %s to end input.", key)
                self.options.path = [self.options.path]
            else:
                # take list of paths
                self.options.path = self.options.path.split(os.pathsep)

                do_recurse = (getattr(self.options, 'recursive', False) or
                              self.jjb_config.recursive)

                excludes = ([e for elist in self.options.exclude
                             for e in elist.split(os.pathsep)] or
                            self.jjb_config.excludes)
                paths = []
                for path in self.options.path:
                    if do_recurse and os.path.isdir(path):
                        paths.extend(utils.recurse_path(path, excludes))
                    else:
                        paths.append(path)
                self.options.path = paths

    def execute(self):

        extension_manager = extension.ExtensionManager(
            namespace='jjb.cli.subcommands',
            invoke_on_load=True,)

#.........这里部分代码省略.........
开发者ID:reddybms,项目名称:jenkins-job-builder,代码行数:101,代码来源:entry.py

示例12: setUp

 def setUp(self):
     super(TestCaseTestJenkinsManager, self).setUp()
     self.jjb_config = JJBConfig()
     self.jjb_config.validate()
开发者ID:phinexus,项目名称:jenkins-job-builder,代码行数:4,代码来源:test_manager.py

示例13: setUp

 def setUp(self):
     super(TestCaseTestBuilder, self).setUp()
     jjb_config = JJBConfig()
     jjb_config.builder['plugins_info'] = ['plugin1', 'plugin2']
     jjb_config.validate()
     self.builder = jenkins_jobs.builder.JenkinsManager(jjb_config)
开发者ID:asdwsda,项目名称:jenkins-job-builder,代码行数:6,代码来源:test_builder.py

示例14: JenkinsJobs

class JenkinsJobs(object):
    """ This is the entry point class for the `jenkins-jobs` command line tool.
    While this class can be used programmatically by external users of the JJB
    API, the main goal here is to abstract the `jenkins_jobs` tool in a way
    that prevents test suites from caring overly much about various
    implementation details--for example, tests of subcommands must not have
    access to directly modify configuration objects, instead they must provide
    a fixture in the form of an .ini file that provides the configuration
    necessary for testing.

    External users of the JJB API may be interested in this class as an
    alternative to wrapping `jenkins_jobs` with a subprocess that execs it as a
    system command; instead, python scripts may be written that pass
    `jenkins_jobs` args directly to this class to allow programmatic setting of
    various command line parameters.
    """

    def __init__(self, args=None, **kwargs):
        if args is None:
            args = []
        self.parser = create_parser()
        self.options = self.parser.parse_args(args)

        self.jjb_config = JJBConfig(self.options.conf, **kwargs)

        if not self.options.command:
            self.parser.error("Must specify a 'command' to be performed")

        logger = logging.getLogger()
        if (self.options.log_level is not None):
            self.options.log_level = getattr(logging,
                                             self.options.log_level.upper(),
                                             logger.getEffectiveLevel())
            logger.setLevel(self.options.log_level)

        self._parse_additional()
        self.jjb_config.validate()

    def _set_config(self, target, option):
        """
        Sets the option in target only if the given option was explicitly set
        """
        opt_val = getattr(self.options, option, None)
        if opt_val is not None:
            target[option] = opt_val

    def _parse_additional(self):

        self._set_config(self.jjb_config.builder, 'ignore_cache')
        self._set_config(self.jjb_config.builder, 'flush_cache')
        self._set_config(self.jjb_config.yamlparser, 'allow_empty_variables')
        self._set_config(self.jjb_config.jenkins, 'user')
        self._set_config(self.jjb_config.jenkins, 'password')

        if getattr(self.options, 'plugins_info_path', None) is not None:
            with io.open(self.options.plugins_info_path, 'r',
                         encoding='utf-8') as yaml_file:
                plugins_info = yaml.load(yaml_file)
            if not isinstance(plugins_info, list):
                self.parser.error("{0} must contain a Yaml list!".format(
                                  self.options.plugins_info_path))
            self.jjb_config.builder['plugins_info'] = plugins_info

        if getattr(self.options, 'path', None):
            if hasattr(self.options.path, 'read'):
                logger.debug("Input file is stdin")
                if self.options.path.isatty():
                    if platform.system() == 'Windows':
                        key = 'CTRL+Z'
                    else:
                        key = 'CTRL+D'
                    logger.warn("Reading configuration from STDIN. "
                                "Press %s to end input.", key)
            else:
                # take list of paths
                self.options.path = self.options.path.split(os.pathsep)

                do_recurse = (getattr(self.options, 'recursive', False) or
                              self.jjb_config.recursive)

                excludes = ([e for elist in self.options.exclude
                             for e in elist.split(os.pathsep)] or
                            self.jjb_config.excludes)
                paths = []
                for path in self.options.path:
                    if do_recurse and os.path.isdir(path):
                        paths.extend(utils.recurse_path(path, excludes))
                    else:
                        paths.append(path)
                self.options.path = paths

    def execute(self):
        options = self.options
        builder = Builder(self.jjb_config)

        if options.command == 'delete':
            for job in options.name:
                builder.delete_job(job, options.path)
        elif options.command == 'delete-all':
            if not utils.confirm(
#.........这里部分代码省略.........
开发者ID:Ladicle,项目名称:jenkins-job-builder,代码行数:101,代码来源:entry.py


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