fix default handling of script-file-path
Fixes the default handling of script-file-path property in script trigger to more closely match the default behavior when saving a job configuration in the Jenkins UI. The previous behavior of setting script-file-path to an empty string resulted in exceptions in the Jenkins log. org.jenkinsci.plugins.scripttrigger.ScriptTriggerException: The script file path '' doesn't exist. Change-Id: I3d07892685c96824041efb102b2a474c22a2b9a7
This commit is contained in:
parent
6a8223e05b
commit
778069e1ad
@ -1117,7 +1117,7 @@ def script(parser, xml_parent, data):
|
||||
|
||||
:arg str label: Restrict where the polling should run. (default '')
|
||||
:arg str script: A shell or batch script. (default '')
|
||||
:arg str script-file-path: A shell or batch script path. (default '')
|
||||
:arg str script-file-path: A shell or batch script path. (optional)
|
||||
:arg str cron: cron syntax of when to run (default '')
|
||||
:arg bool enable-concurrent: Enables triggering concurrent builds.
|
||||
(default false)
|
||||
@ -1136,8 +1136,9 @@ def script(parser, xml_parent, data):
|
||||
label = data.get('label')
|
||||
|
||||
XML.SubElement(st, 'script').text = str(data.get('script', ''))
|
||||
XML.SubElement(st, 'scriptFilePath').text = str(
|
||||
data.get('script-file-path', ''))
|
||||
if 'script-file-path' in data:
|
||||
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:
|
||||
|
@ -3,7 +3,6 @@
|
||||
<triggers class="vector">
|
||||
<org.jenkinsci.plugins.scripttrigger.ScriptTrigger>
|
||||
<script>exit 0</script>
|
||||
<scriptFilePath/>
|
||||
<spec>H/15 * * * *</spec>
|
||||
<labelRestriction>true</labelRestriction>
|
||||
<triggerLabel>master</triggerLabel>
|
14
tests/triggers/fixtures/script002.xml
Normal file
14
tests/triggers/fixtures/script002.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>$WORKSPACE/scripts</scriptFilePath>
|
||||
<spec>H/15 * * * *</spec>
|
||||
<labelRestriction>true</labelRestriction>
|
||||
<triggerLabel>master</triggerLabel>
|
||||
<enableConcurrentBuild>false</enableConcurrentBuild>
|
||||
<exitCode>0</exitCode>
|
||||
</org.jenkinsci.plugins.scripttrigger.ScriptTrigger>
|
||||
</triggers>
|
||||
</project>
|
9
tests/triggers/fixtures/script002.yaml
Normal file
9
tests/triggers/fixtures/script002.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
triggers:
|
||||
- script:
|
||||
script: 'exit 0'
|
||||
script-file-path: '$WORKSPACE/scripts'
|
||||
cron: 'H/15 * * * *'
|
||||
enable-concurrent: False
|
||||
label: master
|
||||
exit-code: 0
|
||||
|
Loading…
Reference in New Issue
Block a user