2017-12-06 13:03:06 +02:00
|
|
|
package com.sap.piper
|
|
|
|
|
2019-01-23 10:48:21 +02:00
|
|
|
@API(deprecated = true)
|
2017-12-06 13:03:06 +02:00
|
|
|
class ConfigurationLoader implements Serializable {
|
2018-05-04 11:34:51 +02:00
|
|
|
static Map stepConfiguration(script, String stepName) {
|
2019-11-26 11:46:56 +02:00
|
|
|
return loadConfiguration(script, 'steps', stepName, ConfigurationType.CUSTOM_CONFIGURATION)
|
2019-08-08 12:47:28 +02:00
|
|
|
}
|
|
|
|
|
2018-05-04 11:34:51 +02:00
|
|
|
static Map stageConfiguration(script, String stageName) {
|
2019-11-26 11:46:56 +02:00
|
|
|
return loadConfiguration(script, 'stages', stageName, ConfigurationType.CUSTOM_CONFIGURATION)
|
2017-12-06 13:03:06 +02:00
|
|
|
}
|
|
|
|
|
2018-05-04 11:34:51 +02:00
|
|
|
static Map defaultStepConfiguration(script, String stepName) {
|
2019-11-26 11:46:56 +02:00
|
|
|
return loadConfiguration(script, 'steps', stepName, ConfigurationType.DEFAULT_CONFIGURATION)
|
2017-12-06 13:03:06 +02:00
|
|
|
}
|
|
|
|
|
2018-05-04 11:34:51 +02:00
|
|
|
static Map defaultStageConfiguration(script, String stageName) {
|
2019-11-26 11:46:56 +02:00
|
|
|
return loadConfiguration(script, 'stages', stageName, ConfigurationType.DEFAULT_CONFIGURATION)
|
2017-12-06 13:03:06 +02:00
|
|
|
}
|
|
|
|
|
2019-11-26 11:46:56 +02:00
|
|
|
static Map generalConfiguration(script){
|
2019-04-04 08:38:54 +02:00
|
|
|
try {
|
2019-11-26 11:46:56 +02:00
|
|
|
return script?.commonPipelineEnvironment?.configuration?.general ?: [:]
|
2019-04-04 08:38:54 +02:00
|
|
|
} catch (groovy.lang.MissingPropertyException mpe) {
|
|
|
|
return [:]
|
|
|
|
}
|
2017-12-06 13:03:06 +02:00
|
|
|
}
|
|
|
|
|
2018-05-04 11:34:51 +02:00
|
|
|
static Map defaultGeneralConfiguration(script){
|
2019-11-26 11:46:56 +02:00
|
|
|
return DefaultValueCache.getInstance()?.getDefaultValues()?.general ?: [:]
|
2017-12-06 13:03:06 +02:00
|
|
|
}
|
|
|
|
|
2018-05-07 10:50:21 +02:00
|
|
|
static Map postActionConfiguration(script, String actionName){
|
2019-11-26 11:46:56 +02:00
|
|
|
return loadConfiguration(script, 'postActions', actionName, ConfigurationType.CUSTOM_CONFIGURATION)
|
2018-05-07 10:50:21 +02:00
|
|
|
}
|
|
|
|
|
2019-11-26 11:46:56 +02:00
|
|
|
private static Map loadConfiguration(script, String type, String entryName, ConfigurationType configType){
|
2017-12-06 13:03:06 +02:00
|
|
|
switch (configType) {
|
|
|
|
case ConfigurationType.CUSTOM_CONFIGURATION:
|
2019-04-04 08:38:54 +02:00
|
|
|
try {
|
2019-11-26 11:46:56 +02:00
|
|
|
return script?.commonPipelineEnvironment?.configuration?.get(type)?.get(entryName) ?: [:]
|
2019-04-04 08:38:54 +02:00
|
|
|
} catch (groovy.lang.MissingPropertyException mpe) {
|
|
|
|
return [:]
|
|
|
|
}
|
|
|
|
|
2017-12-06 13:03:06 +02:00
|
|
|
case ConfigurationType.DEFAULT_CONFIGURATION:
|
|
|
|
return DefaultValueCache.getInstance()?.getDefaultValues()?.get(type)?.get(entryName) ?: [:]
|
|
|
|
default:
|
|
|
|
throw new IllegalArgumentException("Unknown configuration type: ${configType}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|