You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-11-06 09:09:19 +02:00
feat: enable mtaBuild to use cloudMBT (#970)
* enable mtaBuild to use cloudMBT * change name to cloudMbt * change name to cloudMbt * use v1 of cloudMBT
This commit is contained in:
committed by
GitHub
parent
77cd7e1025
commit
74d6df71ef
@@ -331,8 +331,14 @@ steps:
|
||||
logSuccessfulMavenTransfers: false
|
||||
mtaBuild:
|
||||
buildTarget: 'NEO'
|
||||
buildTool: classic
|
||||
platform: 'cf'
|
||||
mtaJarLocation: '/opt/sap/mta/lib/mta.jar'
|
||||
dockerImage: 'ppiper/mta-archive-builder'
|
||||
|
||||
classic:
|
||||
dockerImage: 'ppiper/mta-archive-builder'
|
||||
cloudMbt:
|
||||
dockerImage: 'devxci/mbtci:1.0.0'
|
||||
neoDeploy:
|
||||
dockerImage: 'ppiper/neo-cli'
|
||||
deployMode: 'mta'
|
||||
|
||||
@@ -15,10 +15,15 @@ import static com.sap.piper.Utils.downloadSettingsFromUrl
|
||||
/** The name of the application which is being built. If the parameter has been provided and no `mta.yaml` exists, the `mta.yaml` will be automatically generated using this parameter and the information (`name` and `version`) from `package.json` before the actual build starts.*/
|
||||
'applicationName',
|
||||
/**
|
||||
* The target platform to which the mtar can be deployed.
|
||||
* buildTool classic only: The target platform to which the mtar can be deployed.
|
||||
* @possibleValues 'CF', 'NEO', 'XSA'
|
||||
*/
|
||||
'buildTarget',
|
||||
/**
|
||||
* Tool to use when building the MTA
|
||||
* @possibleValues 'classic', 'cloudMbt'
|
||||
*/
|
||||
'buildTool',
|
||||
/** @see dockerExecute */
|
||||
'dockerImage',
|
||||
/** @see dockerExecute */
|
||||
@@ -36,6 +41,11 @@ 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',
|
||||
/**
|
||||
* buildTool cloudMbt only: The target platform to which the mtar can be deployed.
|
||||
* @possibleValues 'CF', 'NEO', 'XSA'
|
||||
*/
|
||||
'platform',
|
||||
/** Path or url to the mvn settings file that should be used as project settings file.*/
|
||||
'projectSettingsFile'
|
||||
]
|
||||
@@ -60,6 +70,7 @@ void call(Map parameters = [:]) {
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName ?: env.STAGE_NAME, STEP_CONFIG_KEYS)
|
||||
.mixin(parameters, PARAMETER_KEYS)
|
||||
.dependingOn('buildTool').mixin('dockerImage')
|
||||
.use()
|
||||
|
||||
new Utils().pushToSWA([
|
||||
@@ -113,27 +124,33 @@ void call(Map parameters = [:]) {
|
||||
echo "[INFO] '${mtaYamlName}' file found in project sources."
|
||||
}
|
||||
|
||||
def mtaYaml = readYaml file: mtaYamlName
|
||||
|
||||
//[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 = mtaYaml.ID
|
||||
if (!id) {
|
||||
error "Property 'ID' not found in ${mtaYamlName} file."
|
||||
def id = getMtaId(mtaYamlName)
|
||||
|
||||
def mtaCall
|
||||
def options = []
|
||||
options.push("--mtar ${id}.mtar")
|
||||
|
||||
|
||||
switch(configuration.buildTool) {
|
||||
case 'classic':
|
||||
// If it is not configured, it is expected on the PATH
|
||||
def mtaJar = configuration.mtaJarLocation ?: 'mta.jar'
|
||||
options.push("--build-target=${configuration.buildTarget}")
|
||||
if (configuration.extension) options.push("--extension=${configuration.extension}")
|
||||
mtaCall = "java -jar ${mtaJar} ${options.join(' ')} build"
|
||||
break
|
||||
case 'cloudMbt':
|
||||
options.push("--platform ${configuration.platform}")
|
||||
if (configuration.extension) options.push("--extensions=${configuration.extension}")
|
||||
mtaCall = "mbt build ${options.join(' ')}"
|
||||
break
|
||||
default:
|
||||
error "[ERROR][${STEP_NAME}] BuildTool '${configuration.buildTool}' not supported!"
|
||||
}
|
||||
|
||||
def mtarFileName = "${id}.mtar"
|
||||
// If it is not configured, it is expected on the PATH
|
||||
def mtaJar = 'java -jar '
|
||||
mtaJar += configuration.mtaJarLocation ?: 'mta.jar'
|
||||
def buildTarget = configuration.buildTarget
|
||||
|
||||
def mtaCall = "${mtaJar} --mtar ${mtarFileName} --build-target=${buildTarget}"
|
||||
|
||||
if (configuration.extension) mtaCall += " --extension=$configuration.extension"
|
||||
mtaCall += ' build'
|
||||
|
||||
echo "[INFO] Executing mta build call: '${mtaCall}'."
|
||||
|
||||
//[Q]: Why extending the path? [A]: To be sure e.g. grunt can be found
|
||||
@@ -143,7 +160,15 @@ void call(Map parameters = [:]) {
|
||||
$mtaCall
|
||||
"""
|
||||
|
||||
script?.commonPipelineEnvironment?.setMtarFilePath(mtarFileName)
|
||||
script?.commonPipelineEnvironment?.setMtarFilePath("${id}.mtar")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def String getMtaId(String fileName){
|
||||
def mtaYaml = readYaml file: fileName
|
||||
if (!mtaYaml.ID) {
|
||||
error "Property 'ID' not found in ${fileName} file."
|
||||
}
|
||||
return mtaYaml.ID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user