Add support to reverse trigger for job list
Listing jobs as a comma separated list is fine with small amounts of jobs however when this list gets too long it can be difficult to maintain. This patch adds support to list jobs as a list and the code will automatically change it to a python separated list. Also retains support for the old style comma separated list. Change-Id: I0a419bb1f2ec83979f46990430f874381680cac8 Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
This commit is contained in:
parent
d54c7a97fe
commit
833fa2b928
@ -861,13 +861,18 @@ def reverse(parser, xml_parent, data):
|
||||
"Post-build Actions" of an upstream project, but is preferable when you
|
||||
want to configure the downstream project.
|
||||
|
||||
:arg str jobs: List (comma separated) of jobs to watch.
|
||||
:arg str jobs: List of jobs to watch. Can be either a comma separated
|
||||
list or a list.
|
||||
:arg str result: Build results to monitor for between the following
|
||||
options: success, unstable and failure. (default 'success').
|
||||
|
||||
Example:
|
||||
|
||||
.. literalinclude:: /../../tests/triggers/fixtures/reverse.yaml
|
||||
|
||||
Example List:
|
||||
|
||||
.. literalinclude:: /../../tests/triggers/fixtures/reverse-list.yaml
|
||||
"""
|
||||
reserveBuildTrigger = XML.SubElement(
|
||||
xml_parent, 'jenkins.triggers.ReverseBuildTrigger')
|
||||
@ -875,8 +880,12 @@ def reverse(parser, xml_parent, data):
|
||||
supported_thresholds = ['SUCCESS', 'UNSTABLE', 'FAILURE']
|
||||
|
||||
XML.SubElement(reserveBuildTrigger, 'spec').text = ''
|
||||
|
||||
jobs = data.get('jobs')
|
||||
if isinstance(jobs, list):
|
||||
jobs = ",".join(jobs)
|
||||
XML.SubElement(reserveBuildTrigger, 'upstreamProjects').text = \
|
||||
data.get('jobs')
|
||||
jobs
|
||||
|
||||
threshold = XML.SubElement(reserveBuildTrigger, 'threshold')
|
||||
result = data.get('result').upper()
|
||||
|
15
tests/triggers/fixtures/reverse-list.xml
Normal file
15
tests/triggers/fixtures/reverse-list.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<triggers class="vector">
|
||||
<jenkins.triggers.ReverseBuildTrigger>
|
||||
<spec/>
|
||||
<upstreamProjects>a,b,c</upstreamProjects>
|
||||
<threshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</threshold>
|
||||
</jenkins.triggers.ReverseBuildTrigger>
|
||||
</triggers>
|
||||
</project>
|
7
tests/triggers/fixtures/reverse-list.yaml
Normal file
7
tests/triggers/fixtures/reverse-list.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
triggers:
|
||||
- reverse:
|
||||
jobs:
|
||||
- 'a'
|
||||
- 'b'
|
||||
- 'c'
|
||||
result: 'failure'
|
Loading…
Reference in New Issue
Block a user