diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 8cc9fd0e9..9bf91e66c 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -3926,6 +3926,88 @@ def scan_build(parser, xml_parent, data): XML.SubElement(p, 'bugThreshold').text = threshold +def dry(parser, xml_parent, data): + """yaml: dry + Publish trend reports with DRY. + Requires the Jenkins `DRY Plugin. + `_ + + The DRY component accepts a dictionary with the following values: + + :arg str pattern: Report filename pattern (optional) + :arg bool can-run-on-failed: Also runs for failed builds, instead of just + stable or unstable builds (default false) + :arg bool should-detect-modules: Determines if Ant or Maven modules should + be detected for all files that contain warnings (default false) + :arg int healthy: Sunny threshold (optional) + :arg int unhealthy: Stormy threshold (optional) + :arg str health-threshold: Threshold priority for health status + ('low', 'normal' or 'high', defaulted to 'low') + :arg int high-threshold: Minimum number of duplicated lines for high + priority warnings. (default 50) + :arg int normal-threshold: Minimum number of duplicated lines for normal + priority warnings. (default 25) + :arg dict thresholds: Mark build as failed or unstable if the number of + errors exceeds a threshold. (optional) + + :thresholds: + * **unstable** (`dict`) + :unstable: * **total-all** (`int`) + * **total-high** (`int`) + * **total-normal** (`int`) + * **total-low** (`int`) + * **new-all** (`int`) + * **new-high** (`int`) + * **new-normal** (`int`) + * **new-low** (`int`) + + * **failed** (`dict`) + :failed: * **total-all** (`int`) + * **total-high** (`int`) + * **total-normal** (`int`) + * **total-low** (`int`) + * **new-all** (`int`) + * **new-high** (`int`) + * **new-normal** (`int`) + * **new-low** (`int`) + :arg str default-encoding: Encoding for parsing or showing files (optional) + :arg bool do-not-resolve-relative-paths: (default false) + :arg bool dont-compute-new: If set to false, computes new warnings based on + the reference build (default true) + :arg bool use-stable-build-as-reference: The number of new warnings will be + calculated based on the last stable build, allowing reverts of unstable + builds where the number of warnings was decreased. (default false) + :arg bool use-delta-values: If set then the number of new warnings is + calculated by subtracting the total number of warnings of the current + build from the reference build. + (default false) + + Example: + + .. literalinclude:: /../../tests/publishers/fixtures/dry001.yaml + + Full example: + + .. literalinclude:: /../../tests/publishers/fixtures/dry004.yaml + + """ + + xml_element = XML.SubElement(xml_parent, 'hudson.plugins.dry.DryPublisher') + + build_trends_publisher('[DRY] ', xml_element, data) + + # Add specific settings for this trends publisher + settings = [ + ('high-threshold', 'highThreshold', 50), + ('normal-threshold', 'normalThreshold', 25)] + + for key, tag_name, default in settings: + xml_config = XML.SubElement(xml_element, tag_name) + config_value = data.get(key, default) + + xml_config.text = str(config_value) + + def create_publishers(parser, action): dummy_parent = XML.Element("dummy") parser.registry.dispatch('publisher', parser, dummy_parent, action) diff --git a/setup.cfg b/setup.cfg index 95938cc80..38e52dbd0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -132,6 +132,7 @@ jenkins_jobs.publishers = cppcheck=jenkins_jobs.modules.publishers:cppcheck description-setter=jenkins_jobs.modules.publishers:description_setter doxygen=jenkins_jobs.modules.publishers:doxygen + dry=jenkins_jobs.modules.publishers:dry email-ext=jenkins_jobs.modules.publishers:email_ext email=jenkins_jobs.modules.publishers:email emotional-jenkins=jenkins_jobs.modules.publishers:emotional_jenkins diff --git a/tests/publishers/fixtures/dry001.xml b/tests/publishers/fixtures/dry001.xml new file mode 100644 index 000000000..0a5c60b71 --- /dev/null +++ b/tests/publishers/fixtures/dry001.xml @@ -0,0 +1,31 @@ + + + + + 0 + 100 + high + [DRY] + + false + false + false + + + 10 + + + + 1 + + + + false + true + false + **/cpd-result.xml + 50 + 25 + + + diff --git a/tests/publishers/fixtures/dry001.yaml b/tests/publishers/fixtures/dry001.yaml new file mode 100644 index 000000000..3d9487fa9 --- /dev/null +++ b/tests/publishers/fixtures/dry001.yaml @@ -0,0 +1,13 @@ +publishers: + - dry: + pattern: '**/cpd-result.xml' + healthy: 0 + unhealthy: 100 + health-threshold: 'high' + high-threshold: 50 + normal-threshold: 25 + thresholds: + unstable: + total-high: 10 + failed: + total-high: 1 diff --git a/tests/publishers/fixtures/dry002.xml b/tests/publishers/fixtures/dry002.xml new file mode 100644 index 000000000..66aa12326 --- /dev/null +++ b/tests/publishers/fixtures/dry002.xml @@ -0,0 +1,31 @@ + + + + + 0 + 100 + high + [DRY] + utf-8 + true + false + false + + 90 + 80 + 70 + 60 + 90 + 80 + 70 + 60 + + true + true + false + **/cpd-result.xml + 20 + 10 + + + diff --git a/tests/publishers/fixtures/dry002.yaml b/tests/publishers/fixtures/dry002.yaml new file mode 100644 index 000000000..569011464 --- /dev/null +++ b/tests/publishers/fixtures/dry002.yaml @@ -0,0 +1,22 @@ +publishers: + - dry: + pattern: '**/cpd-result.xml' + can-run-on-failed: true + should-detect-modules: true + healthy: 0 + unhealthy: 100 + health-threshold: 'high' + high-threshold: 20 + normal-threshold: 10 + thresholds: + unstable: + total-all: 90 + total-high: 80 + total-normal: 70 + total-low: 60 + failed: + total-all: 90 + total-high: 80 + total-normal: 70 + total-low: 60 + default-encoding: 'utf-8' diff --git a/tests/publishers/fixtures/dry003.xml b/tests/publishers/fixtures/dry003.xml new file mode 100644 index 000000000..ee09bfcb4 --- /dev/null +++ b/tests/publishers/fixtures/dry003.xml @@ -0,0 +1,31 @@ + + + + + + + low + [DRY] + + false + false + false + + + + + + + + + + + false + true + false + + 50 + 25 + + + diff --git a/tests/publishers/fixtures/dry003.yaml b/tests/publishers/fixtures/dry003.yaml new file mode 100644 index 000000000..78b371987 --- /dev/null +++ b/tests/publishers/fixtures/dry003.yaml @@ -0,0 +1,2 @@ +publishers: + - dry diff --git a/tests/publishers/fixtures/dry004.xml b/tests/publishers/fixtures/dry004.xml new file mode 100644 index 000000000..c15d70477 --- /dev/null +++ b/tests/publishers/fixtures/dry004.xml @@ -0,0 +1,39 @@ + + + + + 0 + 100 + high + [DRY] + utf-8 + true + true + true + + 90 + 80 + 70 + 60 + 50 + 40 + 30 + 20 + 91 + 81 + 71 + 61 + 51 + 41 + 31 + 21 + + true + false + true + **/cpd-result.xml + 20 + 10 + + + diff --git a/tests/publishers/fixtures/dry004.yaml b/tests/publishers/fixtures/dry004.yaml new file mode 100644 index 000000000..7d353dda6 --- /dev/null +++ b/tests/publishers/fixtures/dry004.yaml @@ -0,0 +1,34 @@ +publishers: + - dry: + pattern: '**/cpd-result.xml' + can-run-on-failed: true + should-detect-modules: true + healthy: 0 + unhealthy: 100 + health-threshold: 'high' + high-threshold: 20 + normal-threshold: 10 + thresholds: + unstable: + total-all: 90 + total-high: 80 + total-normal: 70 + total-low: 60 + new-all: 50 + new-high: 40 + new-normal: 30 + new-low: 20 + failed: + total-all: 91 + total-high: 81 + total-normal: 71 + total-low: 61 + new-all: 51 + new-high: 41 + new-normal: 31 + new-low: 21 + default-encoding: 'utf-8' + do-not-resolve-relative-paths: true + dont-compute-new: false + use-stable-build-as-reference: true + use-delta-values: true