Add support for Parameterized Scheduler Plugin

Change-Id: I159d2379e316a7ed037ed24b379c519deb1b22ea
Signed-off-by: Fatih Degirmenci <fatih.degirmenci@ericsson.com>
This commit is contained in:
Fatih Degirmenci 2016-08-10 01:34:40 +02:00
parent 0b8c110fb4
commit 29b8249042
5 changed files with 58 additions and 0 deletions

View File

@ -1700,6 +1700,36 @@ def rabbitmq(registry, xml_parent, data):
raise MissingAttributeError(e.arg[0])
def parameterized_timer(parser, xml_parent, data):
"""yaml: parameterized-timer
Trigger builds with parameters at certain times.
Requires the Jenkins :jenkins-wiki:`Parameterized Scheduler Plugin
<Parameterized+Scheduler+Plugin>`.
:arg str cron: cron syntax of when to run and with which parameters
(required)
Example:
.. literalinclude::
/../../tests/triggers/fixtures/parameterized-timer001.yaml
:language: yaml
"""
param_timer = XML.SubElement(
xml_parent,
'org.jenkinsci.plugins.parameterizedscheduler.'
'ParameterizedTimerTrigger')
XML.SubElement(param_timer, 'spec').text = ''
try:
XML.SubElement(param_timer, 'parameterizedSpecification').text = str(
data.get('cron'))
except KeyError as e:
raise MissingAttributeError(e)
class Triggers(jenkins_jobs.modules.base.Base):
sequence = 50

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<triggers class="vector">
<org.jenkinsci.plugins.parameterizedscheduler.ParameterizedTimerTrigger>
<spec/>
<parameterizedSpecification>@midnight % PARAM=value</parameterizedSpecification>
</org.jenkinsci.plugins.parameterizedscheduler.ParameterizedTimerTrigger>
</triggers>
</project>

View File

@ -0,0 +1,3 @@
triggers:
- parameterized-timer:
cron: "@midnight % PARAM=value"

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<triggers class="vector">
<org.jenkinsci.plugins.parameterizedscheduler.ParameterizedTimerTrigger>
<spec/>
<parameterizedSpecification>0 * * * * % param1=value1;param2=value2
30 * * * * % param1=value3;param2=value4
</parameterizedSpecification>
</org.jenkinsci.plugins.parameterizedscheduler.ParameterizedTimerTrigger>
</triggers>
</project>

View File

@ -0,0 +1,5 @@
triggers:
- parameterized-timer:
cron: |
0 * * * * % param1=value1;param2=value2
30 * * * * % param1=value3;param2=value4