1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-04 04:07:16 +02:00

feat(mta): allow configuration of filename for generated mtar (#1030)

* Add new config mtarName for mtaBuild step

* Remove unnecessary whitespace changes in unit test

* Sort new config & avoid file operation when this config provided

* Modify the test to take the custom name without extension

* Update new config documentation

Co-Authored-By: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>

* custom mta name should be given with mtar extension

* Updated the config documentation
This commit is contained in:
Prashanth Madarapu 2019-12-06 12:18:20 +05:30 committed by Christopher Fenner
parent 9ee2926018
commit 7feaa36868
2 changed files with 18 additions and 4 deletions

View File

@ -270,6 +270,14 @@ public class MtaBuildTest extends BasePiperTest {
assert shellRule.shell.find(){ c -> c.contains('java -jar /opt/sap/mta/lib/mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO --extension=config_extension build')}
}
@Test
void canConfigureMTARName() {
stepRule.step.mtaBuild(script: nullScript, mtarName: 'custom.name.mtar')
assert shellRule.shell.find(){ c -> c.contains('--mtar custom.name.mtar')}
}
@Test
void testCloudMbt() {
nullScript.commonPipelineEnvironment.configuration = [steps:[mtaBuild:[mtaBuildTool: 'cloudMbt']]]

View File

@ -41,6 +41,8 @@ import static com.sap.piper.Utils.downloadSettingsFromUrl
'mtaJarLocation',
/** Path or url to the mvn settings file that should be used as global settings file.*/
'globalSettingsFile',
/** The name of the generated mtar file including its extension. */
'mtarName',
/**
* mtaBuildTool cloudMbt only: The target platform to which the mtar can be deployed.
* @possibleValues 'CF', 'NEO', 'XSA'
@ -127,11 +129,15 @@ void call(Map parameters = [:]) {
//[Q]: Why not yaml.dump()? [A]: This reformats the whole file.
sh "sed -ie \"s/\\\${timestamp}/`date +%Y%m%d%H%M%S`/g\" \"${mtaYamlName}\""
def id = getMtaId(mtaYamlName)
def mtaCall
def options = []
options.push("--mtar ${id}.mtar")
String mtarName = configuration.mtarName?.trim()
if (!mtarName) {
def mtaId = getMtaId(mtaYamlName)
mtarName = "${mtaId}.mtar"
}
options.push("--mtar ${mtarName}")
switch(configuration.mtaBuildTool) {
case 'classic':
@ -160,7 +166,7 @@ void call(Map parameters = [:]) {
$mtaCall
"""
script?.commonPipelineEnvironment?.setMtarFilePath("${id}.mtar")
script?.commonPipelineEnvironment?.setMtarFilePath("${mtarName}")
}
}
}