Add script trigger.
Change-Id: I191f8f444f810cf4fe1fb9475aafc747e5dff68d
This commit is contained in:
parent
a32288a573
commit
9c2e6d23ba
@ -454,6 +454,43 @@ def build_result(parser, xml_parent, data):
|
||||
XML.SubElement(model_checked, 'checked').text = result_dict[result]
|
||||
|
||||
|
||||
def script(parser, xml_parent, data):
|
||||
"""yaml: script
|
||||
Triggers the job using shell or batch script.
|
||||
Requires the Jenkins `ScriptTrigger Plugin.
|
||||
<https://wiki.jenkins-ci.org/display/JENKINS/ScriptTrigger+Plugin>`_
|
||||
|
||||
:arg str label: Restrict where the polling should run. (default '')
|
||||
:arg str script: A shell or batch script. (default '')
|
||||
:arg str cron: cron syntax of when to run (default '')
|
||||
:arg bool enable-concurrent: Enables triggering concurrent builds.
|
||||
(default false)
|
||||
:arg int exit-code: If the exit code of the script execution returns this
|
||||
expected exit code, a build is scheduled. (default 0)
|
||||
|
||||
Example:
|
||||
|
||||
.. literalinclude:: /../../tests/triggers/fixtures/script.yaml
|
||||
"""
|
||||
data = data if data else {}
|
||||
st = XML.SubElement(
|
||||
xml_parent,
|
||||
'org.jenkinsci.plugins.scripttrigger.ScriptTrigger'
|
||||
)
|
||||
label = data.get('label')
|
||||
|
||||
XML.SubElement(st, 'script').text = str(data.get('script', ''))
|
||||
XML.SubElement(st, 'scriptFilePath').text = str(
|
||||
data.get('script-file-path', ''))
|
||||
XML.SubElement(st, 'spec').text = str(data.get('cron', ''))
|
||||
XML.SubElement(st, 'labelRestriction').text = str(bool(label)).lower()
|
||||
if label:
|
||||
XML.SubElement(st, 'triggerLabel').text = label
|
||||
XML.SubElement(st, 'enableConcurrentBuild').text = str(
|
||||
data.get('enable-concurrent', False)).lower()
|
||||
XML.SubElement(st, 'exitCode').text = str(data.get('exit-code', 0))
|
||||
|
||||
|
||||
class Triggers(jenkins_jobs.modules.base.Base):
|
||||
sequence = 50
|
||||
|
||||
|
1
setup.py
1
setup.py
@ -190,6 +190,7 @@ setuptools.setup(
|
||||
'github_pull_request'),
|
||||
'pollscm=jenkins_jobs.modules.triggers:pollscm',
|
||||
'timed=jenkins_jobs.modules.triggers:timed',
|
||||
'script=jenkins_jobs.modules.triggers:script',
|
||||
],
|
||||
'jenkins_jobs.wrappers': [
|
||||
'ansicolor=jenkins_jobs.modules.wrappers:ansicolor',
|
||||
|
14
tests/triggers/fixtures/script.xml
Normal file
14
tests/triggers/fixtures/script.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<triggers class="vector">
|
||||
<org.jenkinsci.plugins.scripttrigger.ScriptTrigger>
|
||||
<script>exit 0</script>
|
||||
<scriptFilePath/>
|
||||
<spec>H/15 * * * *</spec>
|
||||
<labelRestriction>true</labelRestriction>
|
||||
<triggerLabel>master</triggerLabel>
|
||||
<enableConcurrentBuild>false</enableConcurrentBuild>
|
||||
<exitCode>0</exitCode>
|
||||
</org.jenkinsci.plugins.scripttrigger.ScriptTrigger>
|
||||
</triggers>
|
||||
</project>
|
8
tests/triggers/fixtures/script.yaml
Normal file
8
tests/triggers/fixtures/script.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
triggers:
|
||||
- script:
|
||||
script: 'exit 0'
|
||||
cron: 'H/15 * * * *'
|
||||
enable-concurrent: False
|
||||
label: master
|
||||
exit-code: 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user