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

Fix compatibility for defaults

This commit is contained in:
Sven Merk 2019-03-07 12:14:25 +01:00
parent 6fd4436494
commit 1f5f812a1a
2 changed files with 10 additions and 9 deletions

View File

@ -9,10 +9,11 @@ class ConfigurationHelper implements Serializable {
new ConfigurationHelper(step, config)
}
ConfigurationHelper loadStepDefaults() {
ConfigurationHelper loadStepDefaults(Map compatibleParameters = [:]) {
this.step.prepareDefaultValues()
this.config = ConfigurationLoader.defaultGeneralConfiguration()
mixin(ConfigurationLoader.defaultStepConfiguration(null, name))
mixin(ConfigurationLoader.defaultGeneralConfiguration(), null, compatibleParameters)
mixin(ConfigurationLoader.defaultStepConfiguration(null, name), null, compatibleParameters)
}
private Map config
@ -71,11 +72,10 @@ class ConfigurationHelper implements Serializable {
}
if (configSubMap == null || (configSubMap != null && configSubMap[entry.getKey()] == null)) {
def stages = entry.getValue()?.tokenize('.')
def configOldSubMap = configMap
def value = resolveToFlat(stages, configOldSubMap)
def paramName = (paramStructure ? paramStructure + '.' : '') + entry.getKey()
def value = resolveToFlat(stages, configMap)
if (value != null) {
newConfig[entry.getKey()] = value
def paramName = (paramStructure ? paramStructure + '.' : '') + entry.getKey()
this.step.echo ("[INFO] The parameter '${entry.getValue()}' is COMPATIBLE to the parameter '${paramName}'")
}
}
@ -84,11 +84,12 @@ class ConfigurationHelper implements Serializable {
return newConfig
}
private String resolveToFlat(List stages, configMap) {
private String resolveToFlat(stages, configMap) {
def first = 0
def result
def configSubMap = configMap[stages[0]]
def configSubMap = configMap[stages[first]]
if(configSubMap instanceof Map) {
stages.remove(0)
stages.remove(first)
result = resolveToFlat(stages, configSubMap)
} else {
result = configSubMap

View File

@ -184,7 +184,7 @@ void call(Map parameters = [:]) {
// load default & individual configuration
Map config = ConfigurationHelper.newInstance(this)
.loadStepDefaults()
.loadStepDefaults(CONFIG_KEY_COMPATIBILITY)
.mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS, CONFIG_KEY_COMPATIBILITY)
.mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS, CONFIG_KEY_COMPATIBILITY)
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName ?: env.STAGE_NAME, STEP_CONFIG_KEYS, CONFIG_KEY_COMPATIBILITY)