diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index b02750e58..5a3b2807a 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -171,22 +171,26 @@ def junit(parser, xml_parent, data): XML.SubElement(junitresult, 'testDataPublishers') -def _pep8_add_entry(xml_parent, name): +def _violations_add_entry(xml_parent, name, data): + vmin = data.get('min', 10) + vmax = data.get('max', 999) + vunstable = data.get('unstable', 999) + pattern = data.get('pattern', None) + entry = XML.SubElement(xml_parent, 'entry') XML.SubElement(entry, 'string').text = name tconfig = XML.SubElement(entry, 'hudson.plugins.violations.TypeConfig') XML.SubElement(tconfig, 'type').text = name - XML.SubElement(tconfig, 'min').text = '10' - XML.SubElement(tconfig, 'max').text = '999' - XML.SubElement(tconfig, 'unstable').text = '999' + XML.SubElement(tconfig, 'min').text = str(vmin) + XML.SubElement(tconfig, 'max').text = str(vmax) + XML.SubElement(tconfig, 'unstable').text = str(vunstable) XML.SubElement(tconfig, 'usePattern').text = 'false' - XML.SubElement(tconfig, 'pattern') + if pattern: + XML.SubElement(tconfig, 'pattern').text = pattern + else: + XML.SubElement(tconfig, 'pattern') - -# Jenkins Job module for pep8 publishers -# No additional YAML needed - -def pep8(parser, xml_parent, data): +def violations(parser, xml_parent, data): violations = XML.SubElement(xml_parent, 'hudson.plugins.violations.ViolationsPublisher') config = XML.SubElement(violations, 'config') @@ -196,31 +200,23 @@ def pep8(parser, xml_parent, data): configs = XML.SubElement(config, 'typeConfigs') XML.SubElement(configs, 'no-comparator') - _pep8_add_entry(configs, 'checkstyle') - _pep8_add_entry(configs, 'codenarc') - _pep8_add_entry(configs, 'cpd') - _pep8_add_entry(configs, 'cpplint') - _pep8_add_entry(configs, 'csslint') - _pep8_add_entry(configs, 'findbugs') - _pep8_add_entry(configs, 'fxcop') - _pep8_add_entry(configs, 'gendarme') - _pep8_add_entry(configs, 'jcreport') - _pep8_add_entry(configs, 'jslint') - - entry = XML.SubElement(configs, 'entry') - XML.SubElement(entry, 'string').text = 'pep8' - tconfig = XML.SubElement(entry, 'hudson.plugins.violations.TypeConfig') - XML.SubElement(tconfig, 'type').text = 'pep8' - XML.SubElement(tconfig, 'min').text = '0' - XML.SubElement(tconfig, 'max').text = '1' - XML.SubElement(tconfig, 'unstable').text = '1' - XML.SubElement(tconfig, 'usePattern').text = 'false' - XML.SubElement(tconfig, 'pattern').text = '**/pep8.txt' - - _pep8_add_entry(configs, 'pmd') - _pep8_add_entry(configs, 'pylint') - _pep8_add_entry(configs, 'simian') - _pep8_add_entry(configs, 'stylecop') + for name in [ + 'checkstyle', + 'codenarc', + 'cpd', + 'cpplint', + 'csslint', + 'findbugs', + 'fxcop', + 'gendarme', + 'jcreport', + 'jslint', + 'pep8', + 'pmd', + 'pylint', + 'simian', + 'stylecop']: + _violations_add_entry(configs, name, data.get(name, {})) XML.SubElement(config, 'limit').text = '100' XML.SubElement(config, 'sourcePathPattern') diff --git a/setup.py b/setup.py index 465a434c8..396e930f5 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ setup(name='jenkins_job_builder', 'coverage=jenkins_jobs.modules.publishers:coverage', 'ftp=jenkins_jobs.modules.publishers:ftp', 'junit=jenkins_jobs.modules.publishers:junit', - 'pep8=jenkins_jobs.modules.publishers:pep8', + 'violations=jenkins_jobs.modules.publishers:violations', 'scp=jenkins_jobs.modules.publishers:scp', ], 'jenkins_jobs.scm': [