Merge "Initial work for supporting downstream-ext"
This commit is contained in:
commit
172963dc16
@ -3814,6 +3814,76 @@ def shining_panda(parser, xml_parent, data):
|
|||||||
data['html-reports-directory'])
|
data['html-reports-directory'])
|
||||||
|
|
||||||
|
|
||||||
|
def downstream_ext(parser, xml_parent, data):
|
||||||
|
"""yaml: downstream-ext
|
||||||
|
Trigger multiple downstream jobs when a job is completed and
|
||||||
|
condition is met.
|
||||||
|
|
||||||
|
Requires the Jenkins :jenkins-wiki:`Downstream-Ext Plugin
|
||||||
|
<Downstream-Ext+Plugin>`.
|
||||||
|
|
||||||
|
:arg list projects: Projects to build (required)
|
||||||
|
:arg string comparison: comparison used for the criteria.
|
||||||
|
One of 'equal-or-over', 'equal-or-under', 'equal'
|
||||||
|
(default: 'equal-or-over')
|
||||||
|
:arg string criteria: Trigger downstream job if build results meets
|
||||||
|
condition. One of 'success', 'unstable', 'failure' or
|
||||||
|
'aborted' (default: 'success')
|
||||||
|
:arg bool only-on-scm-change: Trigger only if downstream project
|
||||||
|
has SCM changes (default: false)
|
||||||
|
:arg bool only-on-local-scm-change: Trigger only if current project
|
||||||
|
has SCM changes (default: false)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
/../../tests/publishers/fixtures/downstream-ext002.yaml
|
||||||
|
:language: yaml
|
||||||
|
"""
|
||||||
|
|
||||||
|
conditions = {
|
||||||
|
"equal-or-over": "AND_HIGHER",
|
||||||
|
"equal-or-under": "AND_LOWER",
|
||||||
|
"equal": "EQUAL"
|
||||||
|
}
|
||||||
|
|
||||||
|
p = XML.SubElement(xml_parent,
|
||||||
|
'hudson.plugins.downstream__ext.DownstreamTrigger')
|
||||||
|
|
||||||
|
if 'projects' not in data:
|
||||||
|
raise JenkinsJobsException("Missing list of downstream projects.")
|
||||||
|
|
||||||
|
XML.SubElement(p, 'childProjects').text = ','.join(data['projects'])
|
||||||
|
|
||||||
|
th = XML.SubElement(p, 'threshold')
|
||||||
|
|
||||||
|
criteria = data.get('criteria', 'success').upper()
|
||||||
|
|
||||||
|
if criteria not in hudson_model.THRESHOLDS:
|
||||||
|
raise JenkinsJobsException("criteria must be one of %s" %
|
||||||
|
", ".join(hudson_model.THRESHOLDS.keys()))
|
||||||
|
|
||||||
|
wr_threshold = hudson_model.THRESHOLDS[
|
||||||
|
criteria]
|
||||||
|
XML.SubElement(th, "name").text = wr_threshold['name']
|
||||||
|
XML.SubElement(th, "ordinal").text = wr_threshold['ordinal']
|
||||||
|
XML.SubElement(th, "color").text = wr_threshold['color']
|
||||||
|
XML.SubElement(th, "completeBuild").text = str(
|
||||||
|
wr_threshold['complete']).lower()
|
||||||
|
|
||||||
|
condition = data.get('condition', 'equal-or-over')
|
||||||
|
if condition not in conditions:
|
||||||
|
raise JenkinsJobsException('condition must be one of: %s' %
|
||||||
|
", ".join(conditions))
|
||||||
|
|
||||||
|
XML.SubElement(p, 'thresholdStrategy').text = conditions[
|
||||||
|
condition]
|
||||||
|
XML.SubElement(p, 'onlyIfSCMChanges').text = str(
|
||||||
|
data.get('only-on-scm-change', False)).lower()
|
||||||
|
XML.SubElement(p, 'onlyIfLocalSCMChanges').text = str(
|
||||||
|
data.get('only-on-local-scm-change', False)).lower()
|
||||||
|
|
||||||
|
|
||||||
def create_publishers(parser, action):
|
def create_publishers(parser, action):
|
||||||
dummy_parent = XML.Element("dummy")
|
dummy_parent = XML.Element("dummy")
|
||||||
parser.registry.dispatch('publisher', parser, dummy_parent, action)
|
parser.registry.dispatch('publisher', parser, dummy_parent, action)
|
||||||
|
@ -139,6 +139,7 @@ jenkins_jobs.publishers =
|
|||||||
coverage=jenkins_jobs.modules.publishers:coverage
|
coverage=jenkins_jobs.modules.publishers:coverage
|
||||||
cppcheck=jenkins_jobs.modules.publishers:cppcheck
|
cppcheck=jenkins_jobs.modules.publishers:cppcheck
|
||||||
description-setter=jenkins_jobs.modules.publishers:description_setter
|
description-setter=jenkins_jobs.modules.publishers:description_setter
|
||||||
|
downstream-ext=jenkins_jobs.modules.publishers:downstream_ext
|
||||||
doxygen=jenkins_jobs.modules.publishers:doxygen
|
doxygen=jenkins_jobs.modules.publishers:doxygen
|
||||||
dry=jenkins_jobs.modules.publishers:dry
|
dry=jenkins_jobs.modules.publishers:dry
|
||||||
email-ext=jenkins_jobs.modules.publishers:email_ext
|
email-ext=jenkins_jobs.modules.publishers:email_ext
|
||||||
|
17
tests/publishers/fixtures/downstream-ext001.xml
Normal file
17
tests/publishers/fixtures/downstream-ext001.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<publishers>
|
||||||
|
<hudson.plugins.downstream__ext.DownstreamTrigger>
|
||||||
|
<childProjects>foo,bar</childProjects>
|
||||||
|
<threshold>
|
||||||
|
<name>SUCCESS</name>
|
||||||
|
<ordinal>0</ordinal>
|
||||||
|
<color>BLUE</color>
|
||||||
|
<completeBuild>true</completeBuild>
|
||||||
|
</threshold>
|
||||||
|
<thresholdStrategy>AND_HIGHER</thresholdStrategy>
|
||||||
|
<onlyIfSCMChanges>false</onlyIfSCMChanges>
|
||||||
|
<onlyIfLocalSCMChanges>false</onlyIfLocalSCMChanges>
|
||||||
|
</hudson.plugins.downstream__ext.DownstreamTrigger>
|
||||||
|
</publishers>
|
||||||
|
</project>
|
5
tests/publishers/fixtures/downstream-ext001.yaml
Normal file
5
tests/publishers/fixtures/downstream-ext001.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
publishers:
|
||||||
|
- downstream-ext:
|
||||||
|
projects:
|
||||||
|
- foo
|
||||||
|
- bar
|
17
tests/publishers/fixtures/downstream-ext002.xml
Normal file
17
tests/publishers/fixtures/downstream-ext002.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<publishers>
|
||||||
|
<hudson.plugins.downstream__ext.DownstreamTrigger>
|
||||||
|
<childProjects>foo,bar</childProjects>
|
||||||
|
<threshold>
|
||||||
|
<name>UNSTABLE</name>
|
||||||
|
<ordinal>1</ordinal>
|
||||||
|
<color>YELLOW</color>
|
||||||
|
<completeBuild>true</completeBuild>
|
||||||
|
</threshold>
|
||||||
|
<thresholdStrategy>EQUAL</thresholdStrategy>
|
||||||
|
<onlyIfSCMChanges>true</onlyIfSCMChanges>
|
||||||
|
<onlyIfLocalSCMChanges>false</onlyIfLocalSCMChanges>
|
||||||
|
</hudson.plugins.downstream__ext.DownstreamTrigger>
|
||||||
|
</publishers>
|
||||||
|
</project>
|
8
tests/publishers/fixtures/downstream-ext002.yaml
Normal file
8
tests/publishers/fixtures/downstream-ext002.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
publishers:
|
||||||
|
- downstream-ext:
|
||||||
|
projects:
|
||||||
|
- foo
|
||||||
|
- bar
|
||||||
|
only-on-scm-change: true
|
||||||
|
criteria: unstable
|
||||||
|
condition: equal
|
Loading…
Reference in New Issue
Block a user