From e043e742678708a6956a2fe53fe7470a3c94d413 Mon Sep 17 00:00:00 2001 From: Kyle Rockman Date: Wed, 29 Apr 2015 14:30:14 -0500 Subject: [PATCH] Adding publisher support to join-trigger plugin the join-trigger plugin supports publishers to be triggered on a join. Only certain publishers work, but this should enable support for it. Change-Id: I04afc2aedd0c57e9e64c46dbdc7f694d47186bbb Signed-off-by: Kyle Rockman --- jenkins_jobs/modules/publishers.py | 13 ++++++++++- tests/publishers/fixtures/join-trigger001.xml | 23 +++++++++++++++++++ .../publishers/fixtures/join-trigger001.yaml | 7 ++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index d6c91ff6a..4ec633bae 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -1966,7 +1966,11 @@ def join_trigger(parser, xml_parent, data): """yaml: join-trigger Trigger a job after all the immediate downstream jobs have completed + :arg bool even-if-unstable: if true jobs will trigger even if some + downstream jobs are marked as unstable (default false) :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 Example: @@ -1975,10 +1979,17 @@ def join_trigger(parser, xml_parent, data): """ jointrigger = XML.SubElement(xml_parent, 'join.JoinTrigger') - # Simple Project List joinProjectsText = ','.join(data.get('projects', [''])) XML.SubElement(jointrigger, 'joinProjects').text = joinProjectsText + publishers = XML.SubElement(jointrigger, 'joinPublishers') + for pub in data.get('publishers', []): + for edited_node in create_publishers(parser, pub): + publishers.append(edited_node) + + unstable = str(data.get('even-if-unstable', 'false')).lower() + XML.SubElement(jointrigger, 'evenIfDownstreamUnstable').text = unstable + def jabber(parser, xml_parent, data): """yaml: jabber diff --git a/tests/publishers/fixtures/join-trigger001.xml b/tests/publishers/fixtures/join-trigger001.xml index 2fdde2071..1d81df4ea 100644 --- a/tests/publishers/fixtures/join-trigger001.xml +++ b/tests/publishers/fixtures/join-trigger001.xml @@ -3,6 +3,29 @@ project-one,project-two + + + + + + + + archive + ALWAYS + false + + + + + + cleanup + ALWAYS + false + + + + + true diff --git a/tests/publishers/fixtures/join-trigger001.yaml b/tests/publishers/fixtures/join-trigger001.yaml index 6caf196a3..a0bba303b 100644 --- a/tests/publishers/fixtures/join-trigger001.yaml +++ b/tests/publishers/fixtures/join-trigger001.yaml @@ -3,3 +3,10 @@ publishers: projects: - project-one - project-two + even-if-unstable: true + publishers: + - trigger-parameterized-builds: + - project: archive + current-parameters: true + - project: cleanup + current-parameters: true