1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-03-03 15:02:35 +02:00

neoDeploy: switch to chained ConfigurationHelper (#244)

* switch neoDeploy to chained ConfigurationHelper

* update imports
This commit is contained in:
Christopher Fenner 2018-08-15 09:26:38 +02:00 committed by GitHub
parent 5e805e4a42
commit 5a742a310f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,36 +1,13 @@
import com.sap.piper.ConfigurationHelper
import com.sap.piper.Utils import com.sap.piper.Utils
import com.sap.piper.ConfigurationLoader
import com.sap.piper.ConfigurationMerger
import com.sap.piper.ConfigurationType
import com.sap.piper.tools.ToolDescriptor import com.sap.piper.tools.ToolDescriptor
import groovy.transform.Field
def call(parameters = [:]) { @Field String STEP_NAME = 'neoDeploy'
@Field Set GENERAL_CONFIG_KEYS = []
def stepName = 'neoDeploy' @Field Set STEP_CONFIG_KEYS = [
Set parameterKeys = [
'applicationName',
'archivePath',
'account',
'deployAccount', //deprecated, replaced by parameter 'account'
'deployHost', //deprecated, replaced by parameter 'host'
'deployMode',
'dockerEnvVars',
'dockerImage',
'dockerOptions',
'host',
'neoCredentialsId',
'neoHome',
'propertiesFile',
'runtime',
'runtimeVersion',
'vmSize',
'warAction'
]
Set stepConfigurationKeys = [
'account', 'account',
'dockerEnvVars', 'dockerEnvVars',
'dockerImage', 'dockerImage',
@ -38,57 +15,71 @@ def call(parameters = [:]) {
'host', 'host',
'neoCredentialsId', 'neoCredentialsId',
'neoHome' 'neoHome'
] ]
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS.plus([
'applicationName',
'archivePath',
'deployAccount', //deprecated, replaced by parameter 'account'
'deployHost', //deprecated, replaced by parameter 'host'
'deployMode',
'propertiesFile',
'runtime',
'runtimeVersion',
'vmSize',
'warAction'
])
handlePipelineStepErrors (stepName: stepName, stepParameters: parameters) { def call(parameters = [:]) {
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
def script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment] def script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
def utils = new Utils() def utils = new Utils()
prepareDefaultValues script: script prepareDefaultValues script: script
final Map stepConfiguration = [:] final Map stepCompatibilityConfiguration = [:]
// Backward compatibility: ensure old configuration is taken into account // Backward compatibility: ensure old configuration is taken into account
// The old configuration in not stage / step specific // The old configuration in not stage / step specific
def defaultDeployHost = script.commonPipelineEnvironment.getConfigProperty('DEPLOY_HOST') def defaultDeployHost = script.commonPipelineEnvironment.getConfigProperty('DEPLOY_HOST')
if(defaultDeployHost) { if(defaultDeployHost) {
echo "[WARNING][${stepName}] A deprecated configuration framework is used for configuring parameter 'DEPLOY_HOST'. This configuration framework will be removed in future versions." echo "[WARNING][${STEP_NAME}] A deprecated configuration framework is used for configuring parameter 'DEPLOY_HOST'. This configuration framework will be removed in future versions."
stepConfiguration.put('host', defaultDeployHost) stepCompatibilityConfiguration.put('host', defaultDeployHost)
} }
def defaultDeployAccount = script.commonPipelineEnvironment.getConfigProperty('CI_DEPLOY_ACCOUNT') def defaultDeployAccount = script.commonPipelineEnvironment.getConfigProperty('CI_DEPLOY_ACCOUNT')
if(defaultDeployAccount) { if(defaultDeployAccount) {
echo "[WARNING][${stepName}] A deprecated configuration framework is used for configuring parameter 'DEPLOY_ACCOUNT'. This configuration framekwork will be removed in future versions." echo "[WARNING][${STEP_NAME}] A deprecated configuration framework is used for configuring parameter 'DEPLOY_ACCOUNT'. This configuration framekwork will be removed in future versions."
stepConfiguration.put('account', defaultDeployAccount) stepCompatibilityConfiguration.put('account', defaultDeployAccount)
} }
if(parameters.deployHost && !parameters.host) { if(parameters.deployHost && !parameters.host) {
echo "[WARNING][${stepName}] Deprecated parameter 'deployHost' is used. This will not work anymore in future versions. Use parameter 'host' instead." echo "[WARNING][${STEP_NAME}] Deprecated parameter 'deployHost' is used. This will not work anymore in future versions. Use parameter 'host' instead."
parameters.put('host', parameters.deployHost) parameters.put('host', parameters.deployHost)
} }
if(parameters.deployAccount && !parameters.account) { if(parameters.deployAccount && !parameters.account) {
echo "[WARNING][${stepName}] Deprecated parameter 'deployAccount' is used. This will not work anymore in future versions. Use parameter 'account' instead." echo "[WARNING][${STEP_NAME}] Deprecated parameter 'deployAccount' is used. This will not work anymore in future versions. Use parameter 'account' instead."
parameters.put('account', parameters.deployAccount) parameters.put('account', parameters.deployAccount)
} }
def credId = script.commonPipelineEnvironment.getConfigProperty('neoCredentialsId') def credId = script.commonPipelineEnvironment.getConfigProperty('neoCredentialsId')
if(credId && !parameters.neoCredentialsId) { if(credId && !parameters.neoCredentialsId) {
echo "[WARNING][${stepName}] Deprecated parameter 'neoCredentialsId' from old configuration framework is used. This will not work anymore in future versions." echo "[WARNING][${STEP_NAME}] Deprecated parameter 'neoCredentialsId' from old configuration framework is used. This will not work anymore in future versions."
parameters.put('neoCredentialsId', credId) parameters.put('neoCredentialsId', credId)
} }
// Backward compatibility end // Backward compatibility end
stepConfiguration.putAll(ConfigurationLoader.stepConfiguration(script, stepName)) // load default & individual configuration
Map configuration = ConfigurationHelper
Map configuration = ConfigurationMerger.merge(parameters, parameterKeys, .loadStepDefaults(this)
stepConfiguration, stepConfigurationKeys, .mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
ConfigurationLoader.defaultStepConfiguration(script, stepName)) .mixin(stepCompatibilityConfiguration)
.mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS)
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, STEP_CONFIG_KEYS)
.mixin(parameters, PARAMETER_KEYS)
.use()
def archivePath = configuration.archivePath def archivePath = configuration.archivePath
if(archivePath?.trim()) { if(archivePath?.trim()) {