1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/vars/prepareDefaultValues.groovy

33 lines
1.3 KiB
Groovy
Raw Normal View History

import com.sap.piper.DefaultValueCache
2018-06-20 10:51:48 +02:00
import com.sap.piper.MapUtils
import hudson.AbortException
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-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-20 10:51:48 +02:00
DefaultValueCache.createInstance(defaultConfiguration)
}
}
}