2017-12-06 13:03:06 +02:00
|
|
|
import com.sap.piper.DefaultValueCache
|
2018-06-20 10:51:48 +02:00
|
|
|
import com.sap.piper.MapUtils
|
2017-12-06 13:03:06 +02:00
|
|
|
|
2018-06-07 09:15:35 +02:00
|
|
|
import hudson.AbortException
|
|
|
|
|
2017-12-06 13:03:06 +02:00
|
|
|
def call(Map parameters = [:]) {
|
|
|
|
handlePipelineStepErrors (stepName: 'prepareDefaultValues', stepParameters: parameters) {
|
2018-06-20 10:51:48 +02:00
|
|
|
if(!DefaultValueCache.getInstance() || parameters.customDefaults) {
|
|
|
|
def configurationFiles = ['default_pipeline_environment.yml']
|
|
|
|
def defaultConfiguration = [:]
|
2018-06-07 09:15:35 +02:00
|
|
|
|
2018-06-20 10:51:48 +02:00
|
|
|
def customDefaults = parameters.customDefaults
|
|
|
|
if(customDefaults in String) // >> filename resolves to Map
|
|
|
|
customDefaults = [].plus(customDefaults)
|
|
|
|
// customDefaults is Map / null
|
|
|
|
configurationFiles += customDefaults
|
|
|
|
/*
|
|
|
|
if(defaults instanceof Map) // >> config map
|
|
|
|
defaults = [].plus(defaults)
|
|
|
|
*/
|
|
|
|
//if(configurationFiles in List) // >> list of String / Map
|
|
|
|
for (def configFileName : configurationFiles){
|
|
|
|
def configuration = readYaml text: libraryResource(configFileName)
|
|
|
|
defaultConfiguration = MapUtils.merge(
|
|
|
|
MapUtils.pruneNull(defaultConfiguration),
|
|
|
|
MapUtils.pruneNull(configuration))
|
2018-06-07 09:15:35 +02:00
|
|
|
}
|
|
|
|
|
2018-06-20 10:51:48 +02:00
|
|
|
DefaultValueCache.createInstance(defaultConfiguration)
|
2017-12-06 13:03:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|