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:
Khai Do
2013-12-06 22:48:55 +00:00
parent 604d39305b
commit b47fe61905
11 changed files with 65 additions and 4 deletions

View File

@@ -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

View File

@@ -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']

View File

@@ -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({}))

View 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>

View File

@@ -0,0 +1,2 @@
name: openstack-infra
project-type: maven

View 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>

View File

@@ -0,0 +1,2 @@
name: openstack-infra
project-type: matrix

View 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>

View File

@@ -0,0 +1,2 @@
name: openstack-infra
project-type: flow

View 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>

View File

@@ -0,0 +1,2 @@
name: openstack-infra
project-type: multijob