1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/vars/prepareDefaultValues.groovy

28 lines
1021 B
Groovy
Raw Normal View History

import com.sap.piper.DefaultValueCache
2018-06-20 10:51:48 +02:00
import com.sap.piper.MapUtils
import groovy.transform.Field
@Field STEP_NAME = getClass().getName()
2018-08-30 16:33:07 +02:00
void call(Map parameters = [:]) {
if(!DefaultValueCache.getInstance() || parameters.customDefaults) {
def defaultValues = [:]
def configFileList = ['default_pipeline_environment.yml']
def customDefaults = parameters.customDefaults
if(customDefaults in String)
customDefaults = [customDefaults]
if(customDefaults in List)
configFileList += customDefaults
for (def configFileName : configFileList){
if(configFileList.size() > 1) echo "Loading configuration file '${configFileName}'"
def configuration = readYaml text: libraryResource(configFileName)
defaultValues = MapUtils.merge(
MapUtils.pruneNulls(defaultValues),
MapUtils.pruneNulls(configuration))
}
DefaultValueCache.createInstance(defaultValues)
}
}