From d3307d6938edfa45470a454b2092fe25ec6870f2 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 14 Mar 2017 13:51:08 +0000 Subject: [PATCH] add two new options to Log Parser Plugin Support both global and per-project rules, and the showGraphs option, both of which became possible in the 2.0 release: https://github.com/jenkinsci/log-parser-plugin/compare/log-parser-1.0.8...log-parser-2.0 https://github.com/jenkinsci/log-parser-plugin/commit/ecde717b9bc618c2d4c8b2526caf10655272148c https://github.com/jenkinsci/log-parser-plugin/commit/6e75ecc8f9f82a17ec151c879dc37d882909df17 Change-Id: I38b0058467d16ca7e3c4d3dc4edb2c9294551f15 --- jenkins_jobs/modules/publishers.py | 20 +++++++++++++++++-- .../{logparser001.xml => logparser-full.xml} | 4 +++- tests/publishers/fixtures/logparser-full.yaml | 7 +++++++ .../publishers/fixtures/logparser-minimal.xml | 12 +++++++++++ .../fixtures/logparser-minimal.yaml | 3 +++ tests/publishers/fixtures/logparser001.yaml | 5 ----- 6 files changed, 43 insertions(+), 8 deletions(-) rename tests/publishers/fixtures/{logparser001.xml => logparser-full.xml} (67%) create mode 100644 tests/publishers/fixtures/logparser-full.yaml create mode 100644 tests/publishers/fixtures/logparser-minimal.xml create mode 100644 tests/publishers/fixtures/logparser-minimal.yaml delete mode 100644 tests/publishers/fixtures/logparser001.yaml diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 18e7e041f..646007d40 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -2335,23 +2335,39 @@ def logparser(registry, xml_parent, data): Requires the Jenkins :jenkins-wiki:`Log Parser Plugin `. :arg str parse-rules: full path to parse rules (default '') + :arg bool use-project-rules: use project rules instead of global + (default true) :arg bool unstable-on-warning: mark build unstable on warning (default false) :arg bool fail-on-error: mark build failed on error (default false) + :arg bool show-graphs: show parser trend graphs (default true) Example: - .. literalinclude:: /../../tests/publishers/fixtures/logparser001.yaml + + Minimal Example: + + .. literalinclude:: /../../tests/publishers/fixtures/logparser-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: /../../tests/publishers/fixtures/logparser-full.yaml :language: yaml """ clog = XML.SubElement(xml_parent, 'hudson.plugins.logparser.LogParserPublisher') clog.set('plugin', 'log-parser') + rules_path_element = ("projectRulePath" + if data.get("use-project-rules", True) + else "parsingRulesPath") mappings = [ ('unstable-on-warning', 'unstableOnWarning', False), ('fail-on-error', 'failBuildOnError', False), - ('parse-rules', 'parsingRulesPath', '') + ('show-graphs', 'showGraphs', True), + ('use-project-rules', 'useProjectRule', True), + ('parse-rules', rules_path_element, ''), ] helpers.convert_mapping_to_xml(clog, data, mappings, fail_required=True) diff --git a/tests/publishers/fixtures/logparser001.xml b/tests/publishers/fixtures/logparser-full.xml similarity index 67% rename from tests/publishers/fixtures/logparser001.xml rename to tests/publishers/fixtures/logparser-full.xml index 15f3f8cfc..caac71683 100644 --- a/tests/publishers/fixtures/logparser001.xml +++ b/tests/publishers/fixtures/logparser-full.xml @@ -4,7 +4,9 @@ true true - /path/to/parserules + false + false + /path/to/global-rules diff --git a/tests/publishers/fixtures/logparser-full.yaml b/tests/publishers/fixtures/logparser-full.yaml new file mode 100644 index 000000000..eaef89522 --- /dev/null +++ b/tests/publishers/fixtures/logparser-full.yaml @@ -0,0 +1,7 @@ +publishers: + - logparser: + use-project-rules: false + parse-rules: "/path/to/global-rules" + unstable-on-warning: true + fail-on-error: true + show-graphs: false diff --git a/tests/publishers/fixtures/logparser-minimal.xml b/tests/publishers/fixtures/logparser-minimal.xml new file mode 100644 index 000000000..681d63fb2 --- /dev/null +++ b/tests/publishers/fixtures/logparser-minimal.xml @@ -0,0 +1,12 @@ + + + + + false + false + true + true + project-log-parser-rules.txt + + + diff --git a/tests/publishers/fixtures/logparser-minimal.yaml b/tests/publishers/fixtures/logparser-minimal.yaml new file mode 100644 index 000000000..78d54c864 --- /dev/null +++ b/tests/publishers/fixtures/logparser-minimal.yaml @@ -0,0 +1,3 @@ +publishers: + - logparser: + parse-rules: "project-log-parser-rules.txt" diff --git a/tests/publishers/fixtures/logparser001.yaml b/tests/publishers/fixtures/logparser001.yaml deleted file mode 100644 index 7749e120d..000000000 --- a/tests/publishers/fixtures/logparser001.yaml +++ /dev/null @@ -1,5 +0,0 @@ -publishers: - - logparser: - parse-rules: "/path/to/parserules" - unstable-on-warning: true - fail-on-error: true