From ee912cbf466ac3a617150bb4fa957cb48ab17039 Mon Sep 17 00:00:00 2001 From: Dong Ma <winterma.dong@gmail.com> Date: Mon, 26 Jun 2017 21:43:28 +0800 Subject: [PATCH] Update dependency_check plugin - update docstring - update test cases Change-Id: I825950ea54977d5ccef7359535a14d67a374bbd8 --- jenkins_jobs/modules/publishers.py | 30 +++++++++------ .../fixtures/dependency-check-full.xml | 38 +++++++++++++++++++ .../fixtures/dependency-check-full.yaml | 33 ++++++++++++++++ ...ck001.xml => dependency-check-minimal.xml} | 4 +- .../fixtures/dependency-check-minimal.yaml | 2 + .../fixtures/dependency-check001.yaml | 4 -- 6 files changed, 93 insertions(+), 18 deletions(-) create mode 100644 tests/publishers/fixtures/dependency-check-full.xml create mode 100644 tests/publishers/fixtures/dependency-check-full.yaml rename tests/publishers/fixtures/{dependency-check001.xml => dependency-check-minimal.xml} (88%) create mode 100644 tests/publishers/fixtures/dependency-check-minimal.yaml delete mode 100644 tests/publishers/fixtures/dependency-check001.yaml diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index b8a085d09..5e09a9078 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -4455,15 +4455,15 @@ def dependency_check(registry, xml_parent, data): :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) + 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) + 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') + ('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) + errors exceeds a threshold. (optional) :thresholds: * **unstable** (`dict`) @@ -4488,21 +4488,27 @@ def dependency_check(registry, xml_parent, data): :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) + 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) + 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) + calculated by subtracting the total number of warnings of the current + build from the reference build. + (default false) - Example: + Minimal Example: .. literalinclude:: - /../../tests/publishers/fixtures/dependency-check001.yaml + /../../tests/publishers/fixtures/dependency-check-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: + /../../tests/publishers/fixtures/dependency-check-full.yaml :language: yaml """ diff --git a/tests/publishers/fixtures/dependency-check-full.xml b/tests/publishers/fixtures/dependency-check-full.xml new file mode 100644 index 000000000..ed71df595 --- /dev/null +++ b/tests/publishers/fixtures/dependency-check-full.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <publishers> + <org.jenkinsci.plugins.DependencyCheck.DependencyCheckPublisher> + <healthy>0</healthy> + <unHealthy>100</unHealthy> + <thresholdLimit>high</thresholdLimit> + <pluginName>[DEPENDENCYCHECK] </pluginName> + <defaultEncoding>utf-8</defaultEncoding> + <canRunOnFailed>true</canRunOnFailed> + <useStableBuildAsReference>true</useStableBuildAsReference> + <usePreviousBuildAsReference>true</usePreviousBuildAsReference> + <useDeltaValues>true</useDeltaValues> + <thresholds> + <unstableTotalAll>90</unstableTotalAll> + <unstableTotalHigh>80</unstableTotalHigh> + <unstableTotalNormal>70</unstableTotalNormal> + <unstableTotalLow>60</unstableTotalLow> + <unstableNewAll>50</unstableNewAll> + <unstableNewHigh>40</unstableNewHigh> + <unstableNewNormal>30</unstableNewNormal> + <unstableNewLow>20</unstableNewLow> + <failedTotalAll>91</failedTotalAll> + <failedTotalHigh>81</failedTotalHigh> + <failedTotalNormal>71</failedTotalNormal> + <failedTotalLow>61</failedTotalLow> + <failedNewAll>51</failedNewAll> + <failedNewHigh>41</failedNewHigh> + <failedNewNormal>31</failedNewNormal> + <failedNewLow>21</failedNewLow> + </thresholds> + <shouldDetectModules>true</shouldDetectModules> + <dontComputeNew>false</dontComputeNew> + <doNotResolveRelativePaths>true</doNotResolveRelativePaths> + <pattern>**/dependency-check-report.xml</pattern> + </org.jenkinsci.plugins.DependencyCheck.DependencyCheckPublisher> + </publishers> +</project> diff --git a/tests/publishers/fixtures/dependency-check-full.yaml b/tests/publishers/fixtures/dependency-check-full.yaml new file mode 100644 index 000000000..88b5f9de1 --- /dev/null +++ b/tests/publishers/fixtures/dependency-check-full.yaml @@ -0,0 +1,33 @@ +publishers: + - dependency-check: + pattern: '**/dependency-check-report.xml' + can-run-on-failed: true + should-detect-modules: true + healthy: 0 + unhealthy: 100 + health-threshold: 'high' + 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-previous-build-as-reference: true + use-stable-build-as-reference: true + use-delta-values: true diff --git a/tests/publishers/fixtures/dependency-check001.xml b/tests/publishers/fixtures/dependency-check-minimal.xml similarity index 88% rename from tests/publishers/fixtures/dependency-check001.xml rename to tests/publishers/fixtures/dependency-check-minimal.xml index 49d2fb1a4..a2dc4ccc3 100644 --- a/tests/publishers/fixtures/dependency-check001.xml +++ b/tests/publishers/fixtures/dependency-check-minimal.xml @@ -8,7 +8,7 @@ <pluginName>[DEPENDENCYCHECK] </pluginName> <defaultEncoding/> <canRunOnFailed>false</canRunOnFailed> - <useStableBuildAsReference>true</useStableBuildAsReference> + <useStableBuildAsReference>false</useStableBuildAsReference> <usePreviousBuildAsReference>false</usePreviousBuildAsReference> <useDeltaValues>false</useDeltaValues> <thresholds> @@ -24,7 +24,7 @@ <shouldDetectModules>false</shouldDetectModules> <dontComputeNew>true</dontComputeNew> <doNotResolveRelativePaths>false</doNotResolveRelativePaths> - <pattern>**/dependency-check-report.xml</pattern> + <pattern/> </org.jenkinsci.plugins.DependencyCheck.DependencyCheckPublisher> </publishers> </project> diff --git a/tests/publishers/fixtures/dependency-check-minimal.yaml b/tests/publishers/fixtures/dependency-check-minimal.yaml new file mode 100644 index 000000000..4e451c1e6 --- /dev/null +++ b/tests/publishers/fixtures/dependency-check-minimal.yaml @@ -0,0 +1,2 @@ +publishers: + - dependency-check diff --git a/tests/publishers/fixtures/dependency-check001.yaml b/tests/publishers/fixtures/dependency-check001.yaml deleted file mode 100644 index 9276392a7..000000000 --- a/tests/publishers/fixtures/dependency-check001.yaml +++ /dev/null @@ -1,4 +0,0 @@ -publishers: - - dependency-check: - pattern: '**/dependency-check-report.xml' - use-stable-build-as-reference: true