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

26 lines
1.1 KiB
Groovy
Raw Normal View History

import com.sap.piper.DefaultValueCache
2018-06-20 10:51:48 +02:00
import com.sap.piper.MapUtils
def 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 10:51:48 +02:00
def configurationFiles = ['default_pipeline_environment.yml']
def customDefaults = parameters.customDefaults
if(customDefaults in String)
2018-06-20 10:51:48 +02:00
customDefaults = [].plus(customDefaults)
2018-06-20 11:16:45 +02:00
if(customDefaults in List)
configurationFiles += customDefaults
2018-06-20 10:51:48 +02:00
for (def configFileName : configurationFiles){
if(configurationFiles.size() > 1) echo "Loading configuration file '${}'"
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)
}
}
}