2017-07-11 15:12:03 +02:00
|
|
|
def call(Map parameters = [:]) {
|
|
|
|
|
|
|
|
handlePipelineStepErrors (stepName: 'setupCommonPipelineEnvironment', stepParameters: parameters) {
|
|
|
|
|
|
|
|
def script = parameters.script
|
|
|
|
|
2017-12-06 13:03:06 +02:00
|
|
|
prepareDefaultValues script: script
|
|
|
|
|
|
|
|
String configFile = parameters.get('configFile')
|
|
|
|
|
|
|
|
loadConfigurationFromFile(script, configFile)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean isYaml(String fileName) {
|
|
|
|
return fileName.endsWith(".yml") || fileName.endsWith(".yaml")
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean isProperties(String fileName) {
|
|
|
|
return fileName.endsWith(".properties")
|
|
|
|
}
|
|
|
|
|
|
|
|
private loadConfigurationFromFile(script, String configFile) {
|
|
|
|
|
|
|
|
String defaultPropertiesConfigFile = '.pipeline/config.properties'
|
|
|
|
String defaultYmlConfigFile = '.pipeline/config.yml'
|
|
|
|
|
|
|
|
if (configFile?.trim()?.length() > 0 && isProperties(configFile)) {
|
|
|
|
Map configMap = readProperties(file: configFile)
|
|
|
|
script.commonPipelineEnvironment.setConfigProperties(configMap)
|
|
|
|
} else if (fileExists(defaultPropertiesConfigFile)) {
|
|
|
|
Map configMap = readProperties(file: defaultPropertiesConfigFile)
|
2017-07-11 15:12:03 +02:00
|
|
|
script.commonPipelineEnvironment.setConfigProperties(configMap)
|
2017-12-06 13:03:06 +02:00
|
|
|
}
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2017-12-06 13:03:06 +02:00
|
|
|
if (configFile?.trim()?.length() > 0 && isYaml(configFile)) {
|
|
|
|
script.commonPipelineEnvironment.configuration = readYaml(file: configFile)
|
|
|
|
} else if (fileExists(defaultYmlConfigFile)) {
|
|
|
|
script.commonPipelineEnvironment.configuration = readYaml(file: defaultYmlConfigFile)
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|
|
|
|
}
|