Update class Workflow to use convert_xml()
Change-Id: I54f45afd3b5218ad6ed7103400458ebfc8135067
This commit is contained in:
parent
f05f2be5f2
commit
e1058a2b5c
@ -50,8 +50,8 @@ Job template example:
|
||||
import logging
|
||||
import xml.etree.ElementTree as XML
|
||||
|
||||
from jenkins_jobs.errors import MissingAttributeError
|
||||
import jenkins_jobs.modules.base
|
||||
from jenkins_jobs.modules.helpers import convert_mapping_to_xml
|
||||
|
||||
|
||||
class Workflow(jenkins_jobs.modules.base.Base):
|
||||
@ -69,13 +69,10 @@ class Workflow(jenkins_jobs.modules.base.Base):
|
||||
{'plugin': 'workflow-cps',
|
||||
'class': 'org.jenkinsci.plugins.'
|
||||
'workflow.cps.CpsFlowDefinition'})
|
||||
try:
|
||||
XML.SubElement(xml_definition, 'script').text = data['dsl']
|
||||
except KeyError as e:
|
||||
raise MissingAttributeError(e.args[0])
|
||||
|
||||
needs_workspace = data.get('sandbox', False)
|
||||
XML.SubElement(xml_definition, 'sandbox').text = str(
|
||||
needs_workspace).lower()
|
||||
mapping = [
|
||||
('dsl', 'script', None),
|
||||
('sandbox', 'sandbox', False)]
|
||||
convert_mapping_to_xml(xml_definition,
|
||||
data, mapping, fail_required=True)
|
||||
|
||||
return xml_parent
|
||||
|
Loading…
Reference in New Issue
Block a user