2018-02-08 14:18:04 +02:00
|
|
|
import com.sap.piper.ConfigurationLoader
|
|
|
|
import com.sap.piper.ConfigurationMerger
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2017-11-24 16:59:34 +02:00
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
def call(Map parameters = [:]) {
|
|
|
|
|
2018-02-08 14:18:04 +02:00
|
|
|
def stepName = 'mtaBuild'
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2018-02-08 14:18:04 +02:00
|
|
|
List parameterKeys = [
|
|
|
|
'buildTarget',
|
|
|
|
'mtaJarLocation'
|
|
|
|
]
|
|
|
|
|
|
|
|
List stepConfigurationKeys = [
|
|
|
|
'buildTarget'
|
|
|
|
]
|
|
|
|
|
|
|
|
List generalConfigurationKeys = [
|
|
|
|
'mtaJarLocation'
|
|
|
|
]
|
|
|
|
|
|
|
|
handlePipelineStepErrors (stepName: stepName, stepParameters: parameters) {
|
|
|
|
|
|
|
|
final script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
|
|
|
|
|
|
|
prepareDefaultValues script: script
|
|
|
|
|
|
|
|
final Map stepConfiguration = ConfigurationLoader.stepConfiguration(script, stepName)
|
|
|
|
final Map stepDefaults = ConfigurationLoader.defaultStepConfiguration(script, stepName)
|
|
|
|
final Map generalConfiguration = ConfigurationLoader.generalConfiguration(script)
|
|
|
|
final Map configuration = ConfigurationMerger.merge(
|
|
|
|
parameters, parameterKeys,
|
|
|
|
generalConfiguration, generalConfigurationKeys, [:],
|
|
|
|
stepConfiguration, stepConfigurationKeys, stepDefaults)
|
2017-07-11 15:12:03 +02:00
|
|
|
|
|
|
|
def mtaYaml = readYaml file: "${pwd()}/mta.yaml"
|
|
|
|
|
|
|
|
//[Q]: Why not yaml.dump()? [A]: This reformats the whole file.
|
2017-11-13 10:26:34 +02:00
|
|
|
sh "sed -ie \"s/\\\${timestamp}/`date +%Y%m%d%H%M%S`/g\" \"${pwd()}/mta.yaml\""
|
2017-07-11 15:12:03 +02:00
|
|
|
|
|
|
|
def id = mtaYaml.ID
|
|
|
|
if (!id) {
|
|
|
|
error "Property 'ID' not found in mta.yaml file at: '${pwd()}'"
|
|
|
|
}
|
|
|
|
|
|
|
|
def mtarFileName = "${id}.mtar"
|
|
|
|
|
2018-02-08 14:18:04 +02:00
|
|
|
def mtaJar = getMtaJar(stepName, configuration)
|
|
|
|
def buildTarget = configuration.buildTarget
|
2017-07-11 15:12:03 +02:00
|
|
|
|
|
|
|
sh """#!/bin/bash
|
|
|
|
export PATH=./node_modules/.bin:${PATH}
|
|
|
|
java -jar ${mtaJar} --mtar ${mtarFileName} --build-target=${buildTarget} build
|
|
|
|
"""
|
|
|
|
|
|
|
|
def mtarFilePath = "${pwd()}/${mtarFileName}"
|
2018-02-08 14:18:04 +02:00
|
|
|
script?.commonPipelineEnvironment?.setMtarFilePath(mtarFilePath)
|
2017-07-11 15:12:03 +02:00
|
|
|
|
|
|
|
return mtarFilePath
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-08 14:18:04 +02:00
|
|
|
private getMtaJar(stepName, configuration) {
|
2017-07-11 15:12:03 +02:00
|
|
|
def mtaJarLocation = 'mta.jar' //default, maybe it is in current working directory
|
|
|
|
|
2018-02-08 14:18:04 +02:00
|
|
|
if(configuration?.mtaJarLocation){
|
|
|
|
mtaJarLocation = "${configuration.mtaJarLocation}/mta.jar"
|
|
|
|
echo "[$stepName] MTA JAR \"${mtaJarLocation}\" retrieved from configuration."
|
2017-07-11 15:12:03 +02:00
|
|
|
return mtaJarLocation
|
|
|
|
}
|
|
|
|
|
|
|
|
if(env?.MTA_JAR_LOCATION){
|
|
|
|
mtaJarLocation = "${env.MTA_JAR_LOCATION}/mta.jar"
|
2018-02-08 14:18:04 +02:00
|
|
|
echo "[$stepName] MTA JAR \"${mtaJarLocation}\" retrieved from environment."
|
2017-07-11 15:12:03 +02:00
|
|
|
return mtaJarLocation
|
|
|
|
}
|
|
|
|
|
2018-02-08 14:18:04 +02:00
|
|
|
echo "[$stepName] Using MTA JAR from current working directory."
|
2017-07-11 15:12:03 +02:00
|
|
|
return mtaJarLocation
|
|
|
|
}
|
2018-02-08 14:18:04 +02:00
|
|
|
|