Merge "Add support for Config File Provider to Maven Project module"

This commit is contained in:
Jenkins 2014-12-13 20:51:57 +00:00 committed by Gerrit Code Review
commit 084eb8122f
3 changed files with 95 additions and 18 deletions

View File

@ -37,9 +37,14 @@ in the :ref:`Job` definition.
a SNAPSHOT dependency is built or not. (default true)
* **automatic-archiving** (`bool`): Activate automatic artifact archiving
(default true).
* **settings** (`str`): Path to custom maven settings file (optional)
* **global-settings** (`str`): Path to custom maven global settings file
* **settings** (`str`): Path to custom maven settings file
It is possible to provide a ConfigFileProvider settings file as well
org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig0123456789012
(optional)
* **global-settings** (`str`): Path to custom maven global settings file
It is possible to provide a ConfigFileProvider settings file as well
org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig
0123456789012 (optional)
Example:
@ -68,10 +73,15 @@ class Maven(jenkins_jobs.modules.base.Base):
'jenkins.mvn.DefaultSettingsProvider',
'settings':
'jenkins.mvn.FilePathSettingsProvider',
'config-file-provider-settings':
'org.jenkinsci.plugins.configfiles.maven.job.MvnSettingsProvider',
'default-global-settings':
'jenkins.mvn.DefaultGlobalSettingsProvider',
'global-settings':
'jenkins.mvn.FilePathGlobalSettingsProvider',
'config-file-provider-global-settings':
'org.jenkinsci.plugins.configfiles.maven.job.'
'MvnGlobalSettingsProvider',
}
def root_xml(self, data):
@ -121,25 +131,55 @@ class Maven(jenkins_jobs.modules.base.Base):
XML.SubElement(xml_parent, 'mavenValidationLevel').text = '-1'
XML.SubElement(xml_parent, 'runHeadless').text = 'false'
if 'settings' in data['maven']:
settings = XML.SubElement(xml_parent, 'settings',
{'class':
self.settings['settings']})
XML.SubElement(settings, 'path').text = str(
data['maven'].get('settings', ''))
# Support for Config File Provider
settings_file = str(data['maven'].get('settings', ''))
if settings_file.startswith(
'org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig'):
settings = XML.SubElement(
xml_parent,
'settings',
{'class': self.settings['config-file-provider-settings']})
XML.SubElement(
settings,
'settingsConfigId').text = settings_file
else:
settings = XML.SubElement(
xml_parent,
'settings',
{'class': self.settings['settings']})
XML.SubElement(settings, 'path').text = settings_file
else:
XML.SubElement(xml_parent, 'settings',
{'class':
self.settings['default-settings']})
XML.SubElement(
xml_parent,
'settings',
{'class': self.settings['default-settings']})
if 'global-settings' in data['maven']:
settings = XML.SubElement(xml_parent, 'globalSettings',
{'class':
self.settings['global-settings']})
XML.SubElement(settings, 'path').text = str(
data['maven'].get('global-settings', ''))
# Support for Config File Provider
global_settings_file = str(data['maven'].get(
'global-settings', ''))
if global_settings_file.startswith(
'org.jenkinsci.plugins.configfiles.maven.'
'GlobalMavenSettingsConfig'):
settings = XML.SubElement(
xml_parent,
'globalSettings',
{'class':
self.settings['config-file-provider-global-settings']})
XML.SubElement(
settings,
'settingsConfigId').text = global_settings_file
else:
settings = XML.SubElement(
xml_parent,
'globalSettings',
{'class': self.settings['global-settings']})
XML.SubElement(settings, 'path').text = str(
data['maven'].get('global-settings', ''))
else:
XML.SubElement(xml_parent, 'globalSettings',
{'class':
self.settings['default-global-settings']})
XML.SubElement(
xml_parent,
'globalSettings',
{'class': self.settings['default-global-settings']})
run_post_steps = XML.SubElement(xml_parent, 'runPostStepsIfResult')
XML.SubElement(run_post_steps, 'name').text = 'FAILURE'

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<maven2-moduleset>
<goals>deploy</goals>
<ignoreUpstremChanges>true</ignoreUpstremChanges>
<rootPOM>pom.xml</rootPOM>
<aggregatorStyleBuild>true</aggregatorStyleBuild>
<incrementalBuild>false</incrementalBuild>
<perModuleEmail>true</perModuleEmail>
<archivingDisabled>false</archivingDisabled>
<resolveDependencies>false</resolveDependencies>
<processPlugins>false</processPlugins>
<mavenValidationLevel>-1</mavenValidationLevel>
<runHeadless>false</runHeadless>
<settings class="org.jenkinsci.plugins.configfiles.maven.job.MvnSettingsProvider">
<settingsConfigId>org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig0123456789012</settingsConfigId>
</settings>
<globalSettings class="org.jenkinsci.plugins.configfiles.maven.job.MvnGlobalSettingsProvider">
<settingsConfigId>org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig0123456789012</settingsConfigId>
</globalSettings>
<runPostStepsIfResult>
<name>FAILURE</name>
<ordinal>2</ordinal>
<color>red</color>
</runPostStepsIfResult>
<actions/>
<keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<concurrentBuild>false</concurrentBuild>
<canRoam>true</canRoam>
</maven2-moduleset>

View File

@ -0,0 +1,6 @@
project-type: maven
maven:
root-pom: pom.xml
goals: deploy
settings: org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig0123456789012
global-settings: org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig0123456789012