mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
71f7f05427
add telemetry to all steps using ConfigurationHelper. Other steps need to be switched to ConfigurationHelper first. update docs
56 lines
1.9 KiB
Groovy
56 lines
1.9 KiB
Groovy
import com.sap.piper.ConfigurationHelper
|
|
import com.sap.piper.Utils
|
|
import groovy.transform.Field
|
|
|
|
@Field String STEP_NAME = 'setupCommonPipelineEnvironment'
|
|
@Field Set GENERAL_CONFIG_KEYS = ['collectTelemetryData']
|
|
|
|
def call(Map parameters = [:]) {
|
|
|
|
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
|
|
|
def script = parameters.script
|
|
|
|
prepareDefaultValues script: script, customDefaults: parameters.customDefaults
|
|
|
|
String configFile = parameters.get('configFile')
|
|
|
|
loadConfigurationFromFile(script, configFile)
|
|
|
|
Map config = ConfigurationHelper
|
|
.loadStepDefaults(this)
|
|
.mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
|
|
.use()
|
|
|
|
new Utils().pushToSWA([step: STEP_NAME, stepParam4: parameters.customDefaults?'true':'false'], config)
|
|
}
|
|
}
|
|
|
|
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)
|
|
script.commonPipelineEnvironment.setConfigProperties(configMap)
|
|
}
|
|
|
|
if (configFile?.trim()?.length() > 0 && isYaml(configFile)) {
|
|
script.commonPipelineEnvironment.configuration = readYaml(file: configFile)
|
|
} else if (fileExists(defaultYmlConfigFile)) {
|
|
script.commonPipelineEnvironment.configuration = readYaml(file: defaultYmlConfigFile)
|
|
}
|
|
}
|