mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
29 lines
1.2 KiB
Groovy
29 lines
1.2 KiB
Groovy
import com.sap.piper.DefaultValueCache
|
|
import com.sap.piper.MapUtils
|
|
|
|
def call(Map parameters = [:]) {
|
|
handlePipelineStepErrors (stepName: 'prepareDefaultValues', stepParameters: parameters) {
|
|
if(!DefaultValueCache.getInstance() || parameters.customDefaults) {
|
|
def defaultValues = [:]
|
|
def configurationFiles = ['default_pipeline_environment.yml']
|
|
def customDefaults = parameters.customDefaults
|
|
|
|
if(customDefaults in String) // >> filename resolves to Map
|
|
customDefaults = [].plus(customDefaults)
|
|
if(customDefaults in List)
|
|
configurationFiles += customDefaults
|
|
/*
|
|
if(defaults instanceof Map) // >> config map
|
|
defaults = [].plus(defaults)
|
|
*/
|
|
for (def configFileName : configurationFiles){
|
|
def configuration = readYaml text: libraryResource(configFileName)
|
|
defaultValues = MapUtils.merge(
|
|
MapUtils.pruneNulls(defaultValues),
|
|
MapUtils.pruneNulls(configuration))
|
|
}
|
|
DefaultValueCache.createInstance(defaultValues)
|
|
}
|
|
}
|
|
}
|