Allow custom settings configs for maven projects
Allow custom settings & global-settings config files to be configured for maven projects. In addition, the previously defined empty nodes for these configurations were misnamed and this corrects that as well. This change also switches to using an included test as an example. Change-Id: I9f832f498e358268b3896ead3a78462e408bdd9d Signed-off-by: Andrew Grimberg <grimbeaj@gmail.com>
This commit is contained in:
parent
72c02d4106
commit
9b32e0fbad
@ -37,22 +37,14 @@ in the :ref:`Job` definition.
|
||||
a SNAPSHOT dependency is built or not. (defaults to true)
|
||||
* **automatic-archiving** (`bool`): Activate automatic artifact archiving
|
||||
(defaults to true).
|
||||
* **settings** (`str`): Path to custom maven settings file (optional)
|
||||
* **global-settings** (`str`): Path to custom maven global settings file
|
||||
(optional)
|
||||
|
||||
Example::
|
||||
Example:
|
||||
|
||||
job:
|
||||
name: doc_job
|
||||
project-type: maven
|
||||
.. literalinclude:: /../../tests/general/fixtures/project-maven001.yaml
|
||||
|
||||
maven:
|
||||
root-module:
|
||||
group-id: org.example.docs
|
||||
artifact-id: example-guide
|
||||
root-pom: doc/src/pom.xml
|
||||
goals: "clean generate-sources"
|
||||
maven-opts: '-Dmyvar=/path/somewhere'
|
||||
maven-name: Maven3
|
||||
automatic-archiving: true
|
||||
"""
|
||||
|
||||
import xml.etree.ElementTree as XML
|
||||
@ -71,6 +63,17 @@ class Maven(jenkins_jobs.modules.base.Base):
|
||||
'hudson.maven.local_repo.PerExecutorLocalRepositoryLocator',
|
||||
}
|
||||
|
||||
settings = {
|
||||
'default-settings':
|
||||
'jenkins.mvn.DefaultSettingsProvider',
|
||||
'settings':
|
||||
'jenkins.mvn.FilePathSettingsProvider',
|
||||
'default-global-settings':
|
||||
'jenkins.mvn.DefaultGlobalSettingsProvider',
|
||||
'global-settings':
|
||||
'jenkins.mvn.FilePathGlobalSettingsProvider',
|
||||
}
|
||||
|
||||
def root_xml(self, data):
|
||||
xml_parent = XML.Element('maven2-moduleset')
|
||||
if 'maven' not in data:
|
||||
@ -117,8 +120,26 @@ class Maven(jenkins_jobs.modules.base.Base):
|
||||
XML.SubElement(xml_parent, 'processPlugins').text = 'false'
|
||||
XML.SubElement(xml_parent, 'mavenValidationLevel').text = '-1'
|
||||
XML.SubElement(xml_parent, 'runHeadless').text = 'false'
|
||||
XML.SubElement(xml_parent, 'settingConfigId')
|
||||
XML.SubElement(xml_parent, 'globalSettingConfigId')
|
||||
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', ''))
|
||||
else:
|
||||
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', ''))
|
||||
else:
|
||||
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'
|
||||
|
@ -15,8 +15,12 @@
|
||||
<processPlugins>false</processPlugins>
|
||||
<mavenValidationLevel>-1</mavenValidationLevel>
|
||||
<runHeadless>false</runHeadless>
|
||||
<settingConfigId/>
|
||||
<globalSettingConfigId/>
|
||||
<settings class="jenkins.mvn.FilePathSettingsProvider">
|
||||
<path>test</path>
|
||||
</settings>
|
||||
<globalSettings class="jenkins.mvn.FilePathGlobalSettingsProvider">
|
||||
<path>test</path>
|
||||
</globalSettings>
|
||||
<runPostStepsIfResult>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
|
@ -5,3 +5,5 @@ maven:
|
||||
root-module:
|
||||
group-id: gabba.gabba
|
||||
artifact-id: hey
|
||||
settings: test
|
||||
global-settings: test
|
||||
|
@ -12,8 +12,8 @@
|
||||
<processPlugins>false</processPlugins>
|
||||
<mavenValidationLevel>-1</mavenValidationLevel>
|
||||
<runHeadless>false</runHeadless>
|
||||
<settingConfigId/>
|
||||
<globalSettingConfigId/>
|
||||
<settings class="jenkins.mvn.DefaultSettingsProvider"/>
|
||||
<globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/>
|
||||
<runPostStepsIfResult>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
|
Loading…
Reference in New Issue
Block a user