diff --git a/jenkins_jobs/modules/project_maven.py b/jenkins_jobs/modules/project_maven.py index e463eb9ee..2054c0265 100755 --- a/jenkins_jobs/modules/project_maven.py +++ b/jenkins_jobs/modules/project_maven.py @@ -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' diff --git a/tests/general/fixtures/project-maven003.xml b/tests/general/fixtures/project-maven003.xml new file mode 100644 index 000000000..0ce68f15c --- /dev/null +++ b/tests/general/fixtures/project-maven003.xml @@ -0,0 +1,31 @@ + + + deploy + true + pom.xml + true + false + true + false + false + false + -1 + false + + org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig0123456789012 + + + org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig0123456789012 + + + FAILURE + 2 + red + + + false + false + false + false + true + diff --git a/tests/general/fixtures/project-maven003.yaml b/tests/general/fixtures/project-maven003.yaml new file mode 100644 index 000000000..ef844ffe1 --- /dev/null +++ b/tests/general/fixtures/project-maven003.yaml @@ -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