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
2019-04-09 11:59:08 +02:00

38 lines
1.4 KiB
Groovy

import com.sap.piper.GenerateDocumentation
import com.sap.piper.DefaultValueCache
import com.sap.piper.MapUtils
import groovy.transform.Field
@Field STEP_NAME = getClass().getName()
@Field Set GENERAL_CONFIG_KEYS = []
@Field Set STEP_CONFIG_KEYS = []
@Field Set PARAMETER_KEYS = []
/**
* Loads the pipeline library default values from the file `resources/default_pipeline_environment.yml`.
* Afterwards the values can be loaded by the method: `ConfigurationLoader.defaultStepConfiguration`
*/
@GenerateDocumentation
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)
}
}