From a580a6240c7520f0be3e0c44ea8c01db319b8267 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 20 Jun 2020 15:24:06 -0700 Subject: publishers: add "threshold" support to join-trigger The joinTrigger plugin now accepts a resultThreshold field instead of the evenIfDownstreamUnstable boolean. Add support for a "threshold" yaml field to manage this value. Change-Id: I60ba999b963709a76854a4d50387d2b1eefae05f Signed-off-by: David Aguilar --- jenkins_jobs/modules/publishers.py | 6 ++++++ tests/publishers/fixtures/join-trigger002.xml | 22 ++++++++++++++++++++++ tests/publishers/fixtures/join-trigger002.yaml | 8 ++++++++ 3 files changed, 36 insertions(+) create mode 100644 tests/publishers/fixtures/join-trigger002.xml create mode 100644 tests/publishers/fixtures/join-trigger002.yaml diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index fc28baed..48bb420c 100755 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -3496,6 +3496,8 @@ def join_trigger(registry, xml_parent, data): :arg list projects: list of projects to trigger :arg list publishers: list of triggers from publishers module that defines projects that need to be triggered + :arg str threshold: result threshold to trigger jobs (optional). + Valid values are "success", "unstable", "failure", and "aborted". :arg bool even-if-unstable: if true jobs will trigger even if some downstream jobs are marked as unstable (default false) (DEPRECATED) @@ -3519,6 +3521,10 @@ def join_trigger(registry, xml_parent, data): if unstable: XML.SubElement(jointrigger, "evenIfDownstreamUnstable").text = unstable + threshold = data.get("threshold", "") + if threshold: + helpers.trigger_threshold(jointrigger, "resultThreshold", threshold) + def jabber(registry, xml_parent, data): """yaml: jabber diff --git a/tests/publishers/fixtures/join-trigger002.xml b/tests/publishers/fixtures/join-trigger002.xml new file mode 100644 index 00000000..9df79716 --- /dev/null +++ b/tests/publishers/fixtures/join-trigger002.xml @@ -0,0 +1,22 @@ + + + + + project-1,project-2 + + FAILURE + 2 + RED + + + + cleanup + + + FAILURE + 2 + RED + + + + diff --git a/tests/publishers/fixtures/join-trigger002.yaml b/tests/publishers/fixtures/join-trigger002.yaml new file mode 100644 index 00000000..80940e47 --- /dev/null +++ b/tests/publishers/fixtures/join-trigger002.yaml @@ -0,0 +1,8 @@ +publishers: + - trigger: + project: project-1,project-2 + threshold: failure + - join-trigger: + projects: + - cleanup + threshold: failure -- cgit