Allow null values for log-text
The log-text parameter is required according to the documentation, but it's perfectly valid for it to be an empty string or null. If the value is null in the yaml, the Python data structure contains None. The code was converting this directly to a string, resulting in 'None' in the xml output. This change makes sure that an empty string is used instead, resulting in a correct empty element in the xml. Change-Id: Ided872f5528bae93347f96bd729b5ce37f8e16fb
This commit is contained in:
parent
bd1c93199a
commit
2a7df4a27a
@ -2956,7 +2956,7 @@ def post_tasks(parser, xml_parent, data):
|
||||
matches_xml,
|
||||
'hudson.plugins.postbuildtask.LogProperties')
|
||||
XML.SubElement(lt_xml, 'logText').text = str(
|
||||
match.get('log-text', ''))
|
||||
match.get('log-text', False) or '')
|
||||
XML.SubElement(lt_xml, 'operator').text = str(
|
||||
match.get('operator', 'AND')).upper()
|
||||
XML.SubElement(task_xml, 'EscalateStatus').text = str(
|
||||
|
21
tests/publishers/fixtures/post-tasks002.xml
Normal file
21
tests/publishers/fixtures/post-tasks002.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.postbuildtask.PostbuildTask>
|
||||
<tasks>
|
||||
<hudson.plugins.postbuildtask.TaskProperties>
|
||||
<logTexts>
|
||||
<hudson.plugins.postbuildtask.LogProperties>
|
||||
<logText/>
|
||||
<operator>AND</operator>
|
||||
</hudson.plugins.postbuildtask.LogProperties>
|
||||
</logTexts>
|
||||
<EscalateStatus>true</EscalateStatus>
|
||||
<RunIfJobSuccessful>true</RunIfJobSuccessful>
|
||||
<script>echo "Here goes the task script"
|
||||
</script>
|
||||
</hudson.plugins.postbuildtask.TaskProperties>
|
||||
</tasks>
|
||||
</hudson.plugins.postbuildtask.PostbuildTask>
|
||||
</publishers>
|
||||
</project>
|
9
tests/publishers/fixtures/post-tasks002.yaml
Normal file
9
tests/publishers/fixtures/post-tasks002.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
publishers:
|
||||
- post-tasks:
|
||||
- matches:
|
||||
- log-text: null
|
||||
operator: AND
|
||||
escalate-status: true
|
||||
run-if-job-successful: true
|
||||
script: |
|
||||
echo "Here goes the task script"
|
Loading…
x
Reference in New Issue
Block a user