make job creation consistent
Defining a project (in yaml) without setting any other parameters should generate a basic jenkins job (in xml). While this works for freestyle jobs, jjb will throw an error for maven and flow projects. The behavior should be consistent across all types of projects. This patch just makes it so that the behavior is consistent. Change-Id: If7b749dae7631e8714a9416dfbd82d2443c0302c
This commit is contained in:
@@ -43,5 +43,9 @@ class Flow(jenkins_jobs.modules.base.Base):
|
||||
|
||||
def root_xml(self, data):
|
||||
xml_parent = XML.Element('com.cloudbees.plugins.flow.BuildFlow')
|
||||
XML.SubElement(xml_parent, 'dsl').text = data['dsl']
|
||||
if 'dsl' in data:
|
||||
XML.SubElement(xml_parent, 'dsl').text = data['dsl']
|
||||
else:
|
||||
XML.SubElement(xml_parent, 'dsl').text = ''
|
||||
|
||||
return xml_parent
|
||||
|
||||
@@ -60,9 +60,9 @@ class Maven(jenkins_jobs.modules.base.Base):
|
||||
sequence = 0
|
||||
|
||||
def root_xml(self, data):
|
||||
if 'maven' not in data:
|
||||
return None
|
||||
xml_parent = XML.Element('maven2-moduleset')
|
||||
if 'maven' not in data:
|
||||
return xml_parent
|
||||
root_module = XML.SubElement(xml_parent, 'rootModule')
|
||||
XML.SubElement(root_module, 'groupId').text = \
|
||||
data['maven']['root-module']['group-id']
|
||||
|
||||
@@ -76,7 +76,20 @@ class BaseTestCase(object):
|
||||
|
||||
yaml_content, expected_xml = self.__read_content()
|
||||
|
||||
xml_project = XML.Element('project') # root element
|
||||
root_element = XML.Element('project')
|
||||
if ('project-type' in yaml_content):
|
||||
if (yaml_content['project-type'] == "maven"):
|
||||
root_element = XML.Element('maven2-moduleset')
|
||||
if (yaml_content['project-type'] == "matrix"):
|
||||
root_element = XML.Element('matrix-project')
|
||||
if (yaml_content['project-type'] == "flow"):
|
||||
root_element = XML.Element('com.cloudbees.plugins.flow.'
|
||||
'BuildFlow')
|
||||
if (yaml_content['project-type'] == "multijob"):
|
||||
root_element = XML.Element('com.tikal.jenkins.plugins.'
|
||||
'multijob.MultiJobProject')
|
||||
|
||||
xml_project = root_element
|
||||
parser = YamlParser()
|
||||
pub = self.klass(ModuleRegistry({}))
|
||||
|
||||
|
||||
9
tests/general/fixtures/project-type001.xml
Normal file
9
tests/general/fixtures/project-type001.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<maven2-moduleset>
|
||||
<actions/>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
</maven2-moduleset>
|
||||
2
tests/general/fixtures/project-type001.yaml
Normal file
2
tests/general/fixtures/project-type001.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
name: openstack-infra
|
||||
project-type: maven
|
||||
9
tests/general/fixtures/project-type002.xml
Normal file
9
tests/general/fixtures/project-type002.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<matrix-project>
|
||||
<actions/>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
</matrix-project>
|
||||
2
tests/general/fixtures/project-type002.yaml
Normal file
2
tests/general/fixtures/project-type002.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
name: openstack-infra
|
||||
project-type: matrix
|
||||
9
tests/general/fixtures/project-type003.xml
Normal file
9
tests/general/fixtures/project-type003.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.cloudbees.plugins.flow.BuildFlow>
|
||||
<actions/>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
</com.cloudbees.plugins.flow.BuildFlow>
|
||||
2
tests/general/fixtures/project-type003.yaml
Normal file
2
tests/general/fixtures/project-type003.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
name: openstack-infra
|
||||
project-type: flow
|
||||
9
tests/general/fixtures/project-type004.xml
Normal file
9
tests/general/fixtures/project-type004.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.tikal.jenkins.plugins.multijob.MultiJobProject>
|
||||
<actions/>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
</com.tikal.jenkins.plugins.multijob.MultiJobProject>
|
||||
2
tests/general/fixtures/project-type004.yaml
Normal file
2
tests/general/fixtures/project-type004.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
name: openstack-infra
|
||||
project-type: multijob
|
||||
Reference in New Issue
Block a user