diff --git a/jenkins_jobs/modules/helpers.py b/jenkins_jobs/modules/helpers.py index 2e04886a4..de00a0368 100644 --- a/jenkins_jobs/modules/helpers.py +++ b/jenkins_jobs/modules/helpers.py @@ -60,6 +60,8 @@ def build_trends_publisher(plugin_name, xml_element, data): ('default-encoding', 'defaultEncoding', ''), ('can-run-on-failed', 'canRunOnFailed', False), ('use-stable-build-as-reference', 'useStableBuildAsReference', False), + ('use-previous-build-as-reference', + 'usePreviousBuildAsReference', False), ('use-delta-values', 'useDeltaValues', False), ('thresholds', 'thresholds', {}), ('should-detect-modules', 'shouldDetectModules', False), @@ -132,9 +134,8 @@ def config_file_provider_settings(xml_parent, data): # For cfp versions <2.10.0 we are able to detect cfp via the config # settings name. - if settings_file.startswith( - 'org.jenkinsci.plugins.configfiles.maven.' - 'MavenSettingsConfig'): + text = 'org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig' + if settings_file.startswith(text): settings_type = 'cfp' if settings_type == 'file': @@ -161,9 +162,9 @@ def config_file_provider_settings(xml_parent, data): # For cfp versions <2.10.0 we are able to detect cfp via the config # settings name. - if global_settings_file.startswith( - 'org.jenkinsci.plugins.configfiles.maven.' - 'GlobalMavenSettingsConfig'): + text = ('org.jenkinsci.plugins.configfiles.maven.' + 'GlobalMavenSettingsConfig') + if global_settings_file.startswith(text): global_settings_type = 'cfp' if global_settings_type == 'file': @@ -242,10 +243,6 @@ def findbugs_settings(xml_parent, data): XML.SubElement(xml_parent, 'includePattern').text = include_files exclude_files = data.get('exclude-files', '') XML.SubElement(xml_parent, 'excludePattern').text = exclude_files - use_previous_build = str(data.get('use-previous-build-as-reference', - False)).lower() - XML.SubElement(xml_parent, - 'usePreviousBuildAsReference').text = use_previous_build def get_value_from_yaml_or_config_file(key, section, data, parser): diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 719f7b913..ed313540f 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -1507,6 +1507,8 @@ def checkstyle(parser, xml_parent, data): :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-previous-build-as-reference: determines whether to always + use the previous build as the reference build (Default false) :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) @@ -3941,6 +3943,76 @@ def stash(parser, xml_parent, data): data.get('include-build-number', False)).lower() +def dependency_check(parser, xml_parent, data): + """yaml: dependency-check + Dependency-Check is an open source utility that identifies project + dependencies and checks if there are any known, publicly disclosed, + vulnerabilities. + + Requires the Jenkins :jenkins-wiki:`OWASP Dependency-Check Plugin + `. + + :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 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-previous-build-as-reference: determines whether to always + use the previous build as the reference build (Default false) + :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/dependency-check001.yaml + :language: yaml + """ + + dependency_check = XML.SubElement( + xml_parent, + 'org.jenkinsci.plugins.DependencyCheck.DependencyCheckPublisher') + + # trends + build_trends_publisher('[DEPENDENCYCHECK] ', dependency_check, data) + + def description_setter(parser, xml_parent, data): """yaml: description-setter This plugin sets the description for each build, @@ -4397,6 +4469,8 @@ def pmd(parser, xml_parent, data): :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-previous-build-as-reference: determines whether to always + use the previous build as the reference build (Default false) :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) @@ -4505,6 +4579,8 @@ def dry(parser, xml_parent, data): :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-previous-build-as-reference: determines whether to always + use the previous build as the reference build (Default false) :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) diff --git a/tests/publishers/fixtures/checkstyle001.xml b/tests/publishers/fixtures/checkstyle001.xml index 06b52cf1a..4c9a5f316 100644 --- a/tests/publishers/fixtures/checkstyle001.xml +++ b/tests/publishers/fixtures/checkstyle001.xml @@ -9,6 +9,7 @@ false false + false false diff --git a/tests/publishers/fixtures/checkstyle002.xml b/tests/publishers/fixtures/checkstyle002.xml index 190a0a115..7e944ece3 100644 --- a/tests/publishers/fixtures/checkstyle002.xml +++ b/tests/publishers/fixtures/checkstyle002.xml @@ -9,6 +9,7 @@ utf-8 true false + false false 90 diff --git a/tests/publishers/fixtures/checkstyle003.xml b/tests/publishers/fixtures/checkstyle003.xml index df211bb81..d3248b3c8 100644 --- a/tests/publishers/fixtures/checkstyle003.xml +++ b/tests/publishers/fixtures/checkstyle003.xml @@ -9,6 +9,7 @@ false false + false false diff --git a/tests/publishers/fixtures/checkstyle004.xml b/tests/publishers/fixtures/checkstyle004.xml index 06b52cf1a..4c9a5f316 100644 --- a/tests/publishers/fixtures/checkstyle004.xml +++ b/tests/publishers/fixtures/checkstyle004.xml @@ -9,6 +9,7 @@ false false + false false diff --git a/tests/publishers/fixtures/checkstyle005.xml b/tests/publishers/fixtures/checkstyle005.xml index 190a0a115..7e944ece3 100644 --- a/tests/publishers/fixtures/checkstyle005.xml +++ b/tests/publishers/fixtures/checkstyle005.xml @@ -9,6 +9,7 @@ utf-8 true false + false false 90 diff --git a/tests/publishers/fixtures/checkstyle006.xml b/tests/publishers/fixtures/checkstyle006.xml index 4cbd96390..5ead1f99b 100644 --- a/tests/publishers/fixtures/checkstyle006.xml +++ b/tests/publishers/fixtures/checkstyle006.xml @@ -9,6 +9,7 @@ utf-8 true true + false true 90 diff --git a/tests/publishers/fixtures/dependency-check001.xml b/tests/publishers/fixtures/dependency-check001.xml new file mode 100644 index 000000000..49d2fb1a4 --- /dev/null +++ b/tests/publishers/fixtures/dependency-check001.xml @@ -0,0 +1,30 @@ + + + + + + + low + [DEPENDENCYCHECK] + + false + true + false + false + + + + + + + + + + + false + true + false + **/dependency-check-report.xml + + + diff --git a/tests/publishers/fixtures/dependency-check001.yaml b/tests/publishers/fixtures/dependency-check001.yaml new file mode 100644 index 000000000..9276392a7 --- /dev/null +++ b/tests/publishers/fixtures/dependency-check001.yaml @@ -0,0 +1,4 @@ +publishers: + - dependency-check: + pattern: '**/dependency-check-report.xml' + use-stable-build-as-reference: true diff --git a/tests/publishers/fixtures/dry001.xml b/tests/publishers/fixtures/dry001.xml index 0a5c60b71..85f10bd2b 100644 --- a/tests/publishers/fixtures/dry001.xml +++ b/tests/publishers/fixtures/dry001.xml @@ -9,6 +9,7 @@ false false + false false diff --git a/tests/publishers/fixtures/dry002.xml b/tests/publishers/fixtures/dry002.xml index 66aa12326..45cbb65dd 100644 --- a/tests/publishers/fixtures/dry002.xml +++ b/tests/publishers/fixtures/dry002.xml @@ -9,6 +9,7 @@ utf-8 true false + false false 90 diff --git a/tests/publishers/fixtures/dry003.xml b/tests/publishers/fixtures/dry003.xml index ee09bfcb4..b03b864ec 100644 --- a/tests/publishers/fixtures/dry003.xml +++ b/tests/publishers/fixtures/dry003.xml @@ -9,6 +9,7 @@ false false + false false diff --git a/tests/publishers/fixtures/dry004.xml b/tests/publishers/fixtures/dry004.xml index c15d70477..3ab575cf2 100644 --- a/tests/publishers/fixtures/dry004.xml +++ b/tests/publishers/fixtures/dry004.xml @@ -9,6 +9,7 @@ utf-8 true true + false true 90 diff --git a/tests/publishers/fixtures/findbugs01.xml b/tests/publishers/fixtures/findbugs01.xml index d2f7bc68e..ff2c3255e 100644 --- a/tests/publishers/fixtures/findbugs01.xml +++ b/tests/publishers/fixtures/findbugs01.xml @@ -5,7 +5,6 @@ true f,d,e,.* a,c,d,.* - true 80 10 high @@ -13,6 +12,7 @@ true true + true true 90 diff --git a/tests/publishers/fixtures/pmd001.xml b/tests/publishers/fixtures/pmd001.xml index 8d046aa6d..f7d2a3b70 100644 --- a/tests/publishers/fixtures/pmd001.xml +++ b/tests/publishers/fixtures/pmd001.xml @@ -9,6 +9,7 @@ false false + false false diff --git a/tests/publishers/fixtures/pmd002.xml b/tests/publishers/fixtures/pmd002.xml index 044911a50..a2ca3167b 100644 --- a/tests/publishers/fixtures/pmd002.xml +++ b/tests/publishers/fixtures/pmd002.xml @@ -9,6 +9,7 @@ utf-8 true false + false false 90 diff --git a/tests/publishers/fixtures/pmd003.xml b/tests/publishers/fixtures/pmd003.xml index 9f0320dcb..79e745318 100644 --- a/tests/publishers/fixtures/pmd003.xml +++ b/tests/publishers/fixtures/pmd003.xml @@ -9,6 +9,7 @@ false false + false false diff --git a/tests/reporters/fixtures/findbugs-minimal.xml b/tests/reporters/fixtures/findbugs-minimal.xml index 21fa9e03d..d00778faa 100644 --- a/tests/reporters/fixtures/findbugs-minimal.xml +++ b/tests/reporters/fixtures/findbugs-minimal.xml @@ -5,7 +5,6 @@ false - false low @@ -13,6 +12,7 @@ false false + false false diff --git a/tests/reporters/fixtures/findbugs01.xml b/tests/reporters/fixtures/findbugs01.xml index 2d8959734..da8f457b8 100644 --- a/tests/reporters/fixtures/findbugs01.xml +++ b/tests/reporters/fixtures/findbugs01.xml @@ -5,7 +5,6 @@ true f,d,e,.* a,c,d,.* - true 80 10 high @@ -13,6 +12,7 @@ true true + true true 90