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-10-09 17:09:55 +02:00
|
|
|
import groovy.transform.Field
|
|
|
|
|
2018-11-29 10:54:05 +02:00
|
|
|
@Field STEP_NAME = getClass().getName()
|
2018-10-09 17:09:55 +02:00
|
|
|
|
2018-08-30 16:33:07 +02:00
|
|
|
void call(Map parameters = [:]) {
|
2017-12-06 13:03:06 +02:00
|
|
|
handlePipelineStepErrors (stepName: 'prepareDefaultValues', stepParameters: parameters) {
|
2018-06-20 10:51:48 +02:00
|
|
|
if(!DefaultValueCache.getInstance() || parameters.customDefaults) {
|
2018-06-20 11:16:45 +02:00
|
|
|
def defaultValues = [:]
|
2018-06-20 13:30:19 +02:00
|
|
|
def configFileList = ['default_pipeline_environment.yml']
|
2018-06-20 10:51:48 +02:00
|
|
|
def customDefaults = parameters.customDefaults
|
2018-06-20 12:00:28 +02:00
|
|
|
|
|
|
|
if(customDefaults in String)
|
2018-06-20 13:28:04 +02:00
|
|
|
customDefaults = [customDefaults]
|
2018-06-20 11:16:45 +02:00
|
|
|
if(customDefaults in List)
|
2018-06-20 13:30:19 +02:00
|
|
|
configFileList += customDefaults
|
|
|
|
for (def configFileName : configFileList){
|
|
|
|
if(configFileList.size() > 1) echo "Loading configuration file '${configFileName}'"
|
2018-06-20 10:51:48 +02:00
|
|
|
def configuration = readYaml text: libraryResource(configFileName)
|
2018-06-20 11:16:45 +02:00
|
|
|
defaultValues = MapUtils.merge(
|
2018-06-20 11:45:42 +02:00
|
|
|
MapUtils.pruneNulls(defaultValues),
|
|
|
|
MapUtils.pruneNulls(configuration))
|
2018-06-07 09:15:35 +02:00
|
|
|
}
|
2018-06-20 11:16:45 +02:00
|
|
|
DefaultValueCache.createInstance(defaultValues)
|
2017-12-06 13:03:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|