diff --git a/test/groovy/MtaBuildTest.groovy b/test/groovy/MtaBuildTest.groovy index b15f6698a..abad22a49 100644 --- a/test/groovy/MtaBuildTest.groovy +++ b/test/groovy/MtaBuildTest.groovy @@ -181,6 +181,14 @@ public class MtaBuildTest extends BasePiperTest { assert 'something' == dockerExecuteRule.dockerParams.dockerOptions } + @Test + void canConfigureMavenUserSettings() { + + stepRule.step.mtaBuild(script: nullScript, projectSettingsFile: 'settings.xml') + + assert shellRule.shell.find(){ c -> c.contains('cp settings.xml $HOME/.m2/settings.xml')} + } + @Test void buildTargetFromDefaultStepConfigurationTest() { diff --git a/vars/mtaBuild.groovy b/vars/mtaBuild.groovy index 774ea8c38..f1f0096c7 100644 --- a/vars/mtaBuild.groovy +++ b/vars/mtaBuild.groovy @@ -26,7 +26,9 @@ import groovy.transform.Field * The location of the SAP Multitarget Application Archive Builder jar file, including file name and extension. * If it is not provided, the SAP Multitarget Application Archive Builder is expected on PATH. */ - 'mtaJarLocation' + 'mtaJarLocation', + /** Path or url to the mvn settings file that should be used as project settings file.*/ + 'projectSettingsFile' ] @Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS.plus([ /** @see dockerExecute */ @@ -59,6 +61,12 @@ void call(Map parameters = [:]) { dockerExecute(script: script, dockerImage: configuration.dockerImage, dockerOptions: configuration.dockerOptions) { + // Apply maven user-settings (for custom repositories, etc) + if (configuration.projectSettingsFile) { + sh 'mkdir -p $HOME/.m2' + sh "cp ${configuration.projectSettingsFile} \$HOME/.m2/settings.xml" + } + def mtaYamlName = "mta.yaml" def applicationName = configuration.applicationName