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

30 lines
1.2 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 groovy.transform.Field
@Field STEP_NAME = 'prepareDefaultValues'
2018-08-30 16:33:07 +02:00
void call(Map parameters = [:]) {
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
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-20 11:16:45 +02:00
DefaultValueCache.createInstance(defaultValues)
}
}
}