From f52cbbe36a128edbed8f181c5631d3fd6ad85ee6 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Mon, 29 Jan 2018 12:50:59 +0100 Subject: [PATCH] Fix wrong backward compatibility handling for deployHost, deployAccount. --- test/groovy/NeoDeploymentTest.groovy | 27 +++++++++++++++++++++++++++ vars/neoDeploy.groovy | 14 ++++++++------ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/test/groovy/NeoDeploymentTest.groovy b/test/groovy/NeoDeploymentTest.groovy index 101f4bb84..a8c915f88 100644 --- a/test/groovy/NeoDeploymentTest.groovy +++ b/test/groovy/NeoDeploymentTest.groovy @@ -468,4 +468,31 @@ class NeoDeploymentTest extends BasePipelineTest { warAction: 'illegalWARAction', vmSize: 'lite') } + + @Test + void deployHostProvidedAsDeprecatedParameterTest() { + new File(workspacePath, archiveName) << "dummy archive" + cpe.setConfigProperty('CI_DEPLOY_ACCOUNT', 'configPropsUser123') + + neoDeployScript.call(script: [commonPipelineEnvironment: cpe], + archivePath: archiveName, + deployHost: "my.deploy.host.com" + ) + + assert jlr.log.contains("[WARNING][neoDeploy] Deprecated parameter 'deployHost' is used. This will not work anymore in future versions. Use parameter 'host' instead.") + } + + @Test + void deployAccountProvidedAsDeprecatedParameterTest() { + new File(workspacePath, archiveName) << "dummy archive" + cpe.setConfigProperty('CI_DEPLOY_ACCOUNT', 'configPropsUser123') + + neoDeployScript.call(script: [commonPipelineEnvironment: cpe], + archivePath: archiveName, + host: "my.deploy.host.com", + deployAccount: "myAccount" + ) + + assert jlr.log.contains("Deprecated parameter 'deployAccount' is used. This will not work anymore in future versions. Use parameter 'account' instead.") + } } diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index e072ee2af..c49fc102c 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -11,6 +11,8 @@ def call(parameters = [:]) { 'applicationName', 'archivePath', 'account', + 'deployAccount', //deprecated, replaced by parameter 'account' + 'deployHost', //deprecated, replaced by parameter 'host' 'deployMode', 'dockerEnvVars', 'dockerImage', @@ -60,14 +62,14 @@ def call(parameters = [:]) { stepConfiguration.put('account', defaultDeployAccount) } - if(parameters.DEPLOY_HOST && !parameters.host) { - echo "[WARNING][${stepName}] Deprecated parameter 'DEPLOY_HOST' is used. This will not work anymore in future versions. Use parameter 'host' instead." - parameters.put('host', parameters.DEPLOY_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." + parameters.put('host', parameters.deployHost) } - if(parameters.CI_DEPLOY_ACCOUNT && !parameters.account) { - echo "[WARNING][${stepName}] Deprecated parameter 'CI_DEPLOY_ACCOUNT' is used. This will not work anymore in future versions. Use parameter 'account' instead." - parameters.put('account', parameters.CI_DEPLOY_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." + parameters.put('account', parameters.deployAccount) } // Backward compatibility end