File 0003-add-two-new-options-to-Log-Parser-Plugin.patch of Package python-jenkins-job-builder
From 6fbcb2856e1dc67671a4cd38abbd502e193ee0cf Mon Sep 17 00:00:00 2001
From: Adam Spiers <aspiers@suse.com>
Date: Tue, 14 Mar 2017 13:51:08 +0000
Subject: [PATCH 2/2] 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
(backported from commit d3307d6938edfa45470a454b2092fe25ec6870f2)
Change-Id: I1f75bc37706b0d7ce8dc2a9d6158a35dbc685a10
---
jenkins_jobs/modules/publishers.py | 22 ++++++++++++++++++++--
tests/publishers/fixtures/logparser-full.xml | 12 ++++++++++++
tests/publishers/fixtures/logparser-full.yaml | 7 +++++++
tests/publishers/fixtures/logparser-minimal.xml | 12 ++++++++++++
tests/publishers/fixtures/logparser-minimal.yaml | 3 +++
tests/publishers/fixtures/logparser001.xml | 10 ----------
tests/publishers/fixtures/logparser001.yaml | 5 -----
7 files changed, 54 insertions(+), 17 deletions(-)
create mode 100644 tests/publishers/fixtures/logparser-full.xml
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.xml
delete mode 100644 tests/publishers/fixtures/logparser001.yaml
diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py
index 47782da..54f7c66 100644
--- a/jenkins_jobs/modules/publishers.py
+++ b/jenkins_jobs/modules/publishers.py
@@ -2077,13 +2077,24 @@ def logparser(parser, xml_parent, data):
Requires the Jenkins :jenkins-wiki:`Log Parser Plugin <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
"""
@@ -2094,7 +2105,14 @@ def logparser(parser, xml_parent, data):
XML.SubElement(clog, 'failBuildOnError').text = \
str(data.get('fail-on-error', False)).lower()
# v1.08: this must be the full path, the name of the rules is not enough
- XML.SubElement(clog, 'parsingRulesPath').text = data.get('parse-rules', '')
+ use_project_rules = data.get("use-project-rules", True)
+ XML.SubElement(clog, 'showGraphs').text = \
+ str(data.get('show-graphs', True)).lower()
+ XML.SubElement(clog, 'useProjectRule').text = \
+ str(use_project_rules).lower()
+ rules_path_element = ("projectRulePath" if use_project_rules
+ else "parsingRulesPath")
+ XML.SubElement(clog, rules_path_element).text = data.get('parse-rules', '')
def copy_to_master(parser, xml_parent, data):
diff --git a/tests/publishers/fixtures/logparser-full.xml b/tests/publishers/fixtures/logparser-full.xml
new file mode 100644
index 0000000..652b478
--- /dev/null
+++ b/tests/publishers/fixtures/logparser-full.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project>
+ <publishers>
+ <hudson.plugins.logparser.LogParserPublisher>
+ <unstableOnWarning>true</unstableOnWarning>
+ <failBuildOnError>true</failBuildOnError>
+ <showGraphs>false</showGraphs>
+ <useProjectRule>false</useProjectRule>
+ <parsingRulesPath>/path/to/global-rules</parsingRulesPath>
+ </hudson.plugins.logparser.LogParserPublisher>
+ </publishers>
+</project>
diff --git a/tests/publishers/fixtures/logparser-full.yaml b/tests/publishers/fixtures/logparser-full.yaml
new file mode 100644
index 0000000..eaef895
--- /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 0000000..67bc7bd
--- /dev/null
+++ b/tests/publishers/fixtures/logparser-minimal.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project>
+ <publishers>
+ <hudson.plugins.logparser.LogParserPublisher>
+ <unstableOnWarning>false</unstableOnWarning>
+ <failBuildOnError>false</failBuildOnError>
+ <showGraphs>true</showGraphs>
+ <useProjectRule>true</useProjectRule>
+ <projectRulePath>project-log-parser-rules.txt</projectRulePath>
+ </hudson.plugins.logparser.LogParserPublisher>
+ </publishers>
+</project>
diff --git a/tests/publishers/fixtures/logparser-minimal.yaml b/tests/publishers/fixtures/logparser-minimal.yaml
new file mode 100644
index 0000000..78d54c8
--- /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.xml b/tests/publishers/fixtures/logparser001.xml
deleted file mode 100644
index 44881b7..0000000
--- a/tests/publishers/fixtures/logparser001.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<project>
- <publishers>
- <hudson.plugins.logparser.LogParserPublisher>
- <unstableOnWarning>true</unstableOnWarning>
- <failBuildOnError>true</failBuildOnError>
- <parsingRulesPath>/path/to/parserules</parsingRulesPath>
- </hudson.plugins.logparser.LogParserPublisher>
- </publishers>
-</project>
diff --git a/tests/publishers/fixtures/logparser001.yaml b/tests/publishers/fixtures/logparser001.yaml
deleted file mode 100644
index 7749e12..0000000
--- 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
--
2.1.2.330.g565301e