Add support for the Naginator Plugin
This plugin allows you to automatically reschedule a build after a build failure. This is useful in several use cases, including: * The build is dependent upon external resources, that were temporarily unavailable. * Users want continuous emails sent out until the build is fixed, in order to prompt people into action Change-Id: Ia292ad98d28b4d708b2419227d8b3c59ec49b254
This commit is contained in:
parent
9481e9207b
commit
ba711838d0
@ -4442,6 +4442,66 @@ def image_gallery(parser, xml_parent, data):
|
||||
include_comparative_elements(gallery_config, gallery_def)
|
||||
|
||||
|
||||
def naginator(parser, xml_parent, data):
|
||||
"""yaml: naginator
|
||||
Automatically reschedule a build after a build failure
|
||||
Requires the Jenkins :jenkins-wiki:`Naginator Plugin <Naginator+Plugin>`.
|
||||
|
||||
:arg bool rerun-unstable-builds: Rerun build for unstable builds as well
|
||||
as failures (default False)
|
||||
:arg int fixed-delay: Fixed delay before retrying build (cannot be used
|
||||
with progressive-delay-increment or progressive-delay-maximum.
|
||||
This is the default delay type. (Default 0)
|
||||
:arg int progressive-delay-increment: Progressive delay before retrying
|
||||
build increment (cannot be used when fixed-delay is being used)
|
||||
(Default 0)
|
||||
:arg int progressive-delay-maximum: Progressive delay before retrying
|
||||
maximum delay (cannot be used when fixed-delay is being used)
|
||||
(Default 0)
|
||||
:arg int max-failed-builds: Maximum number of successive failed builds
|
||||
(Default 0)
|
||||
:arg str regular-expression: Only rerun build if regular expression is
|
||||
found in output (Default '')
|
||||
|
||||
Example:
|
||||
|
||||
.. literalinclude:: /../../tests/publishers/fixtures/naginator001.yaml
|
||||
:language: yaml
|
||||
"""
|
||||
naginator = XML.SubElement(
|
||||
xml_parent,
|
||||
'com.chikli.hudson.plugin.naginator.NaginatorPublisher')
|
||||
XML.SubElement(naginator, 'regexpForRerun').text = str(
|
||||
data.get('regular-expression', ''))
|
||||
XML.SubElement(naginator, 'checkRegexp').text = str(
|
||||
'regular-expression' in data).lower()
|
||||
XML.SubElement(naginator, 'rerunIfUnstable').text = str(
|
||||
data.get('rerun-unstable-builds', False)).lower()
|
||||
progressive_delay = ('progressive-delay-increment' in data or
|
||||
'progressive-delay-maximum' in data)
|
||||
if 'fixed-delay' in data and progressive_delay:
|
||||
raise JenkinsJobsException("You cannot specify both fixed "
|
||||
"and progressive delays")
|
||||
if not progressive_delay:
|
||||
delay = XML.SubElement(
|
||||
naginator,
|
||||
'delay',
|
||||
{'class': 'com.chikli.hudson.plugin.naginator.FixedDelay'})
|
||||
XML.SubElement(delay, 'delay').text = str(
|
||||
data.get('fixed-delay', '0'))
|
||||
else:
|
||||
delay = XML.SubElement(
|
||||
naginator,
|
||||
'delay',
|
||||
{'class': 'com.chikli.hudson.plugin.naginator.ProgressiveDelay'})
|
||||
XML.SubElement(delay, 'increment').text = str(
|
||||
data.get('progressive-delay-increment', '0'))
|
||||
XML.SubElement(delay, 'max').text = str(
|
||||
data.get('progressive-delay-maximum', '0'))
|
||||
XML.SubElement(naginator, 'maxSchedule').text = str(
|
||||
data.get('max-failed-builds', '0'))
|
||||
|
||||
|
||||
class Publishers(jenkins_jobs.modules.base.Base):
|
||||
sequence = 70
|
||||
|
||||
|
@ -175,6 +175,7 @@ jenkins_jobs.publishers =
|
||||
logparser=jenkins_jobs.modules.publishers:logparser
|
||||
logstash=jenkins_jobs.modules.publishers:logstash
|
||||
maven-deploy=jenkins_jobs.modules.publishers:maven_deploy
|
||||
naginator=jenkins_jobs.modules.publishers:naginator
|
||||
performance=jenkins_jobs.modules.publishers:performance
|
||||
pipeline=jenkins_jobs.modules.publishers:pipeline
|
||||
plot=jenkins_jobs.modules.publishers:plot
|
||||
|
15
tests/publishers/fixtures/naginator001.xml
Normal file
15
tests/publishers/fixtures/naginator001.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<com.chikli.hudson.plugin.naginator.NaginatorPublisher>
|
||||
<regexpForRerun>foo</regexpForRerun>
|
||||
<checkRegexp>true</checkRegexp>
|
||||
<rerunIfUnstable>true</rerunIfUnstable>
|
||||
<delay class="com.chikli.hudson.plugin.naginator.ProgressiveDelay">
|
||||
<increment>5</increment>
|
||||
<max>15</max>
|
||||
</delay>
|
||||
<maxSchedule>6</maxSchedule>
|
||||
</com.chikli.hudson.plugin.naginator.NaginatorPublisher>
|
||||
</publishers>
|
||||
</project>
|
7
tests/publishers/fixtures/naginator001.yaml
Normal file
7
tests/publishers/fixtures/naginator001.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
publishers:
|
||||
- naginator:
|
||||
rerun-unstable-builds: true
|
||||
progressive-delay-increment: 5
|
||||
progressive-delay-maximum: 15
|
||||
max-failed-builds: 6
|
||||
regular-expression: "foo"
|
14
tests/publishers/fixtures/naginator002.xml
Normal file
14
tests/publishers/fixtures/naginator002.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<com.chikli.hudson.plugin.naginator.NaginatorPublisher>
|
||||
<regexpForRerun/>
|
||||
<checkRegexp>false</checkRegexp>
|
||||
<rerunIfUnstable>false</rerunIfUnstable>
|
||||
<delay class="com.chikli.hudson.plugin.naginator.FixedDelay">
|
||||
<delay>0</delay>
|
||||
</delay>
|
||||
<maxSchedule>0</maxSchedule>
|
||||
</com.chikli.hudson.plugin.naginator.NaginatorPublisher>
|
||||
</publishers>
|
||||
</project>
|
2
tests/publishers/fixtures/naginator002.yaml
Normal file
2
tests/publishers/fixtures/naginator002.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
publishers:
|
||||
- naginator
|
14
tests/publishers/fixtures/naginator003.xml
Normal file
14
tests/publishers/fixtures/naginator003.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<com.chikli.hudson.plugin.naginator.NaginatorPublisher>
|
||||
<regexpForRerun/>
|
||||
<checkRegexp>false</checkRegexp>
|
||||
<rerunIfUnstable>false</rerunIfUnstable>
|
||||
<delay class="com.chikli.hudson.plugin.naginator.FixedDelay">
|
||||
<delay>30</delay>
|
||||
</delay>
|
||||
<maxSchedule>6</maxSchedule>
|
||||
</com.chikli.hudson.plugin.naginator.NaginatorPublisher>
|
||||
</publishers>
|
||||
</project>
|
4
tests/publishers/fixtures/naginator003.yaml
Normal file
4
tests/publishers/fixtures/naginator003.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
publishers:
|
||||
- naginator:
|
||||
fixed-delay: 30
|
||||
max-failed-builds: 6
|
Loading…
x
Reference in New Issue
Block a user