2018-09-21 16:55:31 +02:00
|
|
|
import static com.sap.piper.Prerequisites.checkScript
|
|
|
|
|
2019-04-03 11:13:08 +02:00
|
|
|
import com.sap.piper.GenerateDocumentation
|
2018-08-06 08:57:36 +02:00
|
|
|
import com.sap.piper.ConfigurationHelper
|
|
|
|
import com.sap.piper.Utils
|
2019-04-11 11:39:41 +02:00
|
|
|
import com.sap.piper.analytics.InfluxData
|
|
|
|
|
2018-08-06 08:57:36 +02:00
|
|
|
import groovy.transform.Field
|
|
|
|
|
2018-11-29 10:54:05 +02:00
|
|
|
@Field String STEP_NAME = getClass().getName()
|
2018-08-06 08:57:36 +02:00
|
|
|
|
2019-04-03 11:13:08 +02:00
|
|
|
@Field Set GENERAL_CONFIG_KEYS = [
|
|
|
|
/** */
|
|
|
|
'collectTelemetryData'
|
|
|
|
]
|
|
|
|
|
|
|
|
@Field Set STEP_CONFIG_KEYS = []
|
|
|
|
|
|
|
|
@Field Set PARAMETER_KEYS = [
|
|
|
|
/** Property file defining project specific settings.*/
|
|
|
|
'configFile'
|
|
|
|
]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the [`commonPipelineEnvironment`](commonPipelineEnvironment.md), which is used throughout the complete pipeline.
|
|
|
|
*
|
|
|
|
* !!! tip
|
|
|
|
* This step needs to run at the beginning of a pipeline right after the SCM checkout.
|
|
|
|
* Then subsequent pipeline steps consume the information from `commonPipelineEnvironment`; it does not need to be passed to pipeline steps explicitly.
|
|
|
|
*/
|
|
|
|
@GenerateDocumentation
|
2018-08-30 16:33:07 +02:00
|
|
|
void call(Map parameters = [:]) {
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2018-08-09 11:35:33 +02:00
|
|
|
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2018-09-21 16:55:31 +02:00
|
|
|
def script = checkScript(this, parameters)
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2018-06-20 10:51:48 +02:00
|
|
|
prepareDefaultValues script: script, customDefaults: parameters.customDefaults
|
2017-12-06 13:03:06 +02:00
|
|
|
|
|
|
|
String configFile = parameters.get('configFile')
|
|
|
|
|
|
|
|
loadConfigurationFromFile(script, configFile)
|
2018-08-06 08:57:36 +02:00
|
|
|
|
2018-10-17 11:05:20 +02:00
|
|
|
Map config = ConfigurationHelper.newInstance(this)
|
2018-09-07 10:08:16 +02:00
|
|
|
.loadStepDefaults()
|
2018-08-06 08:57:36 +02:00
|
|
|
.mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
|
|
|
|
.use()
|
|
|
|
|
2019-01-21 09:47:34 +02:00
|
|
|
(parameters.utils ?: new Utils()).pushToSWA([
|
|
|
|
step: STEP_NAME,
|
|
|
|
stepParamKey4: 'customDefaults',
|
2019-03-26 15:13:03 +02:00
|
|
|
stepParam4: parameters.customDefaults?'true':'false'
|
2019-01-21 09:47:34 +02:00
|
|
|
], config)
|
2019-03-21 21:23:23 +02:00
|
|
|
|
2019-04-11 11:39:41 +02:00
|
|
|
InfluxData.addField('step_data', 'build_url', env.BUILD_URL)
|
|
|
|
InfluxData.addField('pipeline_data', 'build_url', env.BUILD_URL)
|
2017-12-06 13:03:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private loadConfigurationFromFile(script, String configFile) {
|
|
|
|
|
|
|
|
String defaultYmlConfigFile = '.pipeline/config.yml'
|
|
|
|
|
2019-03-26 15:13:03 +02:00
|
|
|
if (configFile) {
|
2017-12-06 13:03:06 +02:00
|
|
|
script.commonPipelineEnvironment.configuration = readYaml(file: configFile)
|
|
|
|
} else if (fileExists(defaultYmlConfigFile)) {
|
|
|
|
script.commonPipelineEnvironment.configuration = readYaml(file: defaultYmlConfigFile)
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|
|
|
|
}
|