From 09a2e3f09089273b3a7240ea3ef8a8f54f68f612 Mon Sep 17 00:00:00 2001 From: Daniel Kurzynski Date: Mon, 28 Jan 2019 12:35:35 +0100 Subject: [PATCH 1/2] Remove compatibility for neoDeploy --- .../FioriOnCloudPlatformPipelineTest.groovy | 8 +- test/groovy/NeoDeployTest.groovy | 127 ------------------ vars/neoDeploy.groovy | 81 +---------- 3 files changed, 8 insertions(+), 208 deletions(-) diff --git a/test/groovy/FioriOnCloudPlatformPipelineTest.groovy b/test/groovy/FioriOnCloudPlatformPipelineTest.groovy index 09b81a195..83500f7d6 100644 --- a/test/groovy/FioriOnCloudPlatformPipelineTest.groovy +++ b/test/groovy/FioriOnCloudPlatformPipelineTest.groovy @@ -115,9 +115,11 @@ class FioriOnCloudPlatformPipelineTest extends BasePiperTest { .commonPipelineEnvironment .configuration = [steps: [neoDeploy: - [ host: 'hana.example.com', - account: 'myTestAccount', - ] + [neo: + [ host: 'hana.example.com', + account: 'myTestAccount', + ] + ] ] ] diff --git a/test/groovy/NeoDeployTest.groovy b/test/groovy/NeoDeployTest.groovy index a97d5ee6e..202183c8a 100644 --- a/test/groovy/NeoDeployTest.groovy +++ b/test/groovy/NeoDeployTest.groovy @@ -89,104 +89,6 @@ class NeoDeployTest extends BasePiperTest { nullScript.commonPipelineEnvironment.configuration = [steps: [neoDeploy: [neo: [host: 'test.deploy.host.com', account: 'trialuser123']]]] } - @Test - void straightForwardTestCompatibilityConfiguration(){ - shellRule.setReturnValue(JenkinsShellCallRule.Type.REGEX, '.* status .*', 'Status: STARTED') - - nullScript.commonPipelineEnvironment.configuration = [ - steps: [ - neoDeploy: [ - host: 'test.deploy.host.com', - account: 'trialuser123', - neoCredentialsId: 'myCredentialsId' - ]]] - - stepRule.step.neoDeploy(script: nullScript, - archivePath: warArchiveName, - deployMode: 'warParams', - applicationName: 'testApp', - runtime: 'neo-javaee6-wp', - runtimeVersion: '2.125', - warAction: 'rolling-update', - vmSize: 'lite') - - Assert.assertThat(shellRule.shell, - new CommandLineMatcher().hasProlog("\"/opt/neo/tools/neo.sh\" rolling-update") - .hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com') - .hasSingleQuotedOption('account', 'trialuser123') - .hasSingleQuotedOption('application', 'testApp') - .hasSingleQuotedOption('runtime', 'neo-javaee6-wp') - .hasSingleQuotedOption('runtime-version', '2\\.125') - .hasSingleQuotedOption('size', 'lite') - .hasSingleQuotedOption('user', 'anonymous') - .hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*') - .hasSingleQuotedOption('source', '.*\\.war')) - } - - @Test - void straightForwardTestConfigViaConfigProperties() { - - boolean buildStatusHasBeenSet = false - boolean notifyOldConfigFrameworkUsed = false - - nullScript.commonPipelineEnvironment.setConfigProperty('DEPLOY_HOST', 'test.deploy.host.com') - nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'trialuser123') - nullScript.commonPipelineEnvironment.configuration = [:] - - nullScript.currentBuild = [setResult: { buildStatusHasBeenSet = true }] - - def utils = new Utils() { - void pushToSWA(Map parameters, Map config) { - notifyOldConfigFrameworkUsed = parameters.stepParam4 - } - } - - stepRule.step.neoDeploy(script: nullScript, - source: archiveName, - neo: [credentialsId: 'myCredentialsId'], - utils: utils - ) - - Assert.assertThat(shellRule.shell, - new CommandLineMatcher().hasProlog("\"/opt/neo/tools/neo.sh\" deploy-mta") - .hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com') - .hasSingleQuotedOption('account', 'trialuser123') - .hasOption('synchronous', '') - .hasSingleQuotedOption('user', 'anonymous') - .hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*') - .hasSingleQuotedOption('source', '.*')) - - assert !buildStatusHasBeenSet - assert notifyOldConfigFrameworkUsed - } - - @Test - void testConfigViaConfigPropertiesSetsBuildToUnstable() { - - def buildStatus = 'SUCCESS' - - nullScript.commonPipelineEnvironment.setConfigProperty('DEPLOY_HOST', 'test.deploy.host.com') - nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'trialuser123') - nullScript.commonPipelineEnvironment.configuration = [:] - - nullScript.currentBuild = [setResult: { r -> buildStatus = r }] - - System.setProperty('com.sap.piper.featureFlag.buildUnstableWhenOldConfigFrameworkIsUsedByNeoDeploy', - Boolean.TRUE.toString()) - - try { - stepRule.step.neoDeploy(script: nullScript, - source: archiveName, - neo:[credentialsId: 'myCredentialsId'], - utils: utils - ) - } finally { - System.clearProperty('com.sap.piper.featureFlag.buildUnstableWhenOldConfigFrameworkIsUsedByNeoDeploy') - } - - assert buildStatus == 'UNSTABLE' - } - @Test void straightForwardTestConfigViaConfiguration() { @@ -655,35 +557,6 @@ class NeoDeployTest extends BasePiperTest { ]) } - @Test - void deployHostProvidedAsDeprecatedParameterTest() { - - nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'configPropsUser123') - - stepRule.step.neoDeploy(script: nullScript, - source: archiveName, - deployHost: "my.deploy.host.com" - ) - - assert loggingRule.log.contains("[WARNING][neoDeploy] Deprecated parameter 'deployHost' is used. This will not work anymore in future versions. Use parameter 'host' instead.") - } - - @Test - void deployAccountProvidedAsDeprecatedParameterTest() { - - nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'configPropsUser123') - - stepRule.step.neoDeploy(script: nullScript, - source: archiveName, - neo: [ - host: "my.deploy.host.com", - ], - deployAccount: "myAccount" - ) - - assert loggingRule.log.contains("Deprecated parameter 'deployAccount' is used. This will not work anymore in future versions. Use parameter 'account' instead.") - } - private mockShellCommands() { String javaVersion = '''openjdk version \"1.8.0_121\" OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-1~bpo8+1-b13) diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index a239452dd..e4a373fae 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -25,21 +25,6 @@ import static com.sap.piper.Prerequisites.checkScript 'warAction' ]) -@Field Map CONFIG_KEY_COMPATIBILITY = [ - neo : [ - host : 'host', - account : 'account', - application : 'applicationName', - credentialsId : 'neoCredentialsId', - propertiesFile: 'propertiesFile', - runtime : 'runtime', - runtimeVersion: 'runtimeVersion', - size : 'vmSize' - - ], - source: 'archivePath' -] - void call(parameters = [:]) { handlePipelineStepErrors(stepName: STEP_NAME, stepParameters: parameters) { @@ -49,17 +34,14 @@ void call(parameters = [:]) { prepareDefaultValues script: script - Map stepCompatibilityConfiguration = handleCompatibility(script, parameters) - // load default & individual configuration Map configuration = ConfigurationHelper.newInstance(this) .loadStepDefaults() .mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS) - .mixin(stepCompatibilityConfiguration) - .mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS, CONFIG_KEY_COMPATIBILITY) - .mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName ?: env.STAGE_NAME, STEP_CONFIG_KEYS, CONFIG_KEY_COMPATIBILITY) + .mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS) + .mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName ?: env.STAGE_NAME, STEP_CONFIG_KEYS) .addIfEmpty('source', script.commonPipelineEnvironment.getMtarFilePath()) - .mixin(parameters, PARAMETER_KEYS, CONFIG_KEY_COMPATIBILITY) + .mixin(parameters, PARAMETER_KEYS) .withMandatoryProperty('neo') .withMandatoryProperty('source') .withPropertyInValues('deployMode', DeployMode.stringValues()) @@ -73,8 +55,6 @@ void call(parameters = [:]) { stepParam2: configuration.warAction == 'rolling-update'?'blue-green':'standard', // ['deploy', 'deploy-mta', 'rolling-update'] stepParamKey3: 'scriptMissing', stepParam3: parameters?.script == null, - stepParamKey4: 'legacyConfig', - stepParam4: !stepCompatibilityConfiguration.isEmpty(), ], configuration) ToolDescriptor neo = new ToolDescriptor('SAP Cloud Platform Console Client', 'NEO_HOME', 'neoHome', '/tools/', 'neo.sh', null, 'version') @@ -168,61 +148,6 @@ private boolean isAppRunning(NeoCommandHelper commandHelper) { return status.contains('Status: STARTED') } -private handleCompatibility(script, parameters) { - final Map neoCompatibilityConfiguration = [:] - - // Backward compatibility: ensure old configuration is taken into account - // The old configuration in not stage / step specific - - def defaultDeployHost = script.commonPipelineEnvironment.getConfigProperty('DEPLOY_HOST') - if (defaultDeployHost) { - echo "[WARNING][${STEP_NAME}] A deprecated configuration framework is used for configuring parameter 'DEPLOY_HOST'. This configuration framework will be removed in future versions." - neoCompatibilityConfiguration.put('host', defaultDeployHost) - } - - def defaultDeployAccount = script.commonPipelineEnvironment.getConfigProperty('CI_DEPLOY_ACCOUNT') - if (defaultDeployAccount) { - echo "[WARNING][${STEP_NAME}] A deprecated configuration framework is used for configuring parameter 'DEPLOY_ACCOUNT'. This configuration framekwork will be removed in future versions." - neoCompatibilityConfiguration.put('account', defaultDeployAccount) - } - - if (parameters.deployHost && !parameters.host) { - 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) - } - - if (parameters.deployAccount && !parameters.account) { - 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) - } - - def credId = script.commonPipelineEnvironment.getConfigProperty('neoCredentialsId') - if (credId && !parameters.neoCredentialsId) { - 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) - } - - if (!neoCompatibilityConfiguration.isEmpty()) { - echo "[WARNING][$STEP_NAME] You are using a deprecated configuration framework. This will be removed in " + - 'futureVersions.\nAdd snippet below to \'./pipeline/config.yml\' and remove ' + - 'file \'.pipeline/configuration.properties\'.\n' + - """|steps: - | neoDeploy: - | neo: - | host: ${neoCompatibilityConfiguration.get('host', '')} - | account: ${neoCompatibilityConfiguration.get('account', '')} - """.stripMargin() - - if (Boolean.getBoolean('com.sap.piper.featureFlag.buildUnstableWhenOldConfigFrameworkIsUsedByNeoDeploy')) { - script.currentBuild.setResult('UNSTABLE') - echo "[WARNING][$STEP_NAME] Build has been set to unstable since old config framework is used." - } - return [neo: neoCompatibilityConfiguration] - } - - return [:] -} - private assertPasswordRules(String password) { if (password.startsWith("@")) { error("Your password for the deployment to SAP Cloud Platform contains characters which are not " + From a7bc198342a6f2a40a70e330471059b94595ecee Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Thu, 7 Mar 2019 12:53:25 +0100 Subject: [PATCH 2/2] neo toolset not configurable (#484) --- .../piper/tools/neo/NeoCommandHelper.groovy | 6 +- .../FioriOnCloudPlatformPipelineTest.groovy | 2 +- test/groovy/NeoDeployTest.groovy | 110 ++---------------- .../tools/neo/NeoCommandHelperTest.groovy | 20 ++-- vars/neoDeploy.groovy | 10 -- 5 files changed, 23 insertions(+), 125 deletions(-) diff --git a/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy b/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy index c58687cac..58ebcc7fb 100644 --- a/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy +++ b/src/com/sap/piper/tools/neo/NeoCommandHelper.groovy @@ -9,25 +9,23 @@ class NeoCommandHelper { private Script step private DeployMode deployMode private Map deploymentConfiguration - private String pathToNeoExecutable private String user private String password private String source //Warning: Commands generated with this class can contain passwords and should only be used within the step withCredentials - NeoCommandHelper(Script step, DeployMode deployMode, Map deploymentConfiguration, String pathToNeoExecutable, + NeoCommandHelper(Script step, DeployMode deployMode, Map deploymentConfiguration, String user, String password, String source) { this.step = step this.deployMode = deployMode this.deploymentConfiguration = deploymentConfiguration - this.pathToNeoExecutable = pathToNeoExecutable this.user = user this.password = password this.source = source } private String prolog() { - return "\"${pathToNeoExecutable}\"" + return 'neo.sh' } String statusCommand() { diff --git a/test/groovy/FioriOnCloudPlatformPipelineTest.groovy b/test/groovy/FioriOnCloudPlatformPipelineTest.groovy index 83500f7d6..8c695b2be 100644 --- a/test/groovy/FioriOnCloudPlatformPipelineTest.groovy +++ b/test/groovy/FioriOnCloudPlatformPipelineTest.groovy @@ -141,7 +141,7 @@ class FioriOnCloudPlatformPipelineTest extends BasePiperTest { // the neo deploy call: Assert.assertThat(shellRule.shell, new CommandLineMatcher() - .hasProlog("\"/opt/sap/neo/tools/neo.sh\" deploy-mta") + .hasProlog("neo.sh deploy-mta") .hasSingleQuotedOption('host', 'hana\\.example\\.com') .hasSingleQuotedOption('account', 'myTestAccount') .hasSingleQuotedOption('password', 'terceSpot') diff --git a/test/groovy/NeoDeployTest.groovy b/test/groovy/NeoDeployTest.groovy index 202183c8a..d4d93c7a5 100644 --- a/test/groovy/NeoDeployTest.groovy +++ b/test/groovy/NeoDeployTest.groovy @@ -84,7 +84,6 @@ class NeoDeployTest extends BasePiperTest { helper.registerAllowedMethod('dockerExecute', [Map, Closure], null) helper.registerAllowedMethod('fileExists', [String], { s -> return new File(workspacePath, s).exists() }) helper.registerAllowedMethod('pwd', [], { return workspacePath }) - mockShellCommands() nullScript.commonPipelineEnvironment.configuration = [steps: [neoDeploy: [neo: [host: 'test.deploy.host.com', account: 'trialuser123']]]] } @@ -107,7 +106,7 @@ class NeoDeployTest extends BasePiperTest { ) Assert.assertThat(shellRule.shell, - new CommandLineMatcher().hasProlog("\"/opt/neo/tools/neo.sh\" deploy-mta") + new CommandLineMatcher().hasProlog("neo.sh deploy-mta") .hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com') .hasSingleQuotedOption('account', 'trialuser123') .hasOption('synchronous', '') @@ -133,7 +132,7 @@ class NeoDeployTest extends BasePiperTest { ) Assert.assertThat(shellRule.shell, - new CommandLineMatcher().hasProlog("\"/opt/neo/tools/neo.sh\" deploy-mta") + new CommandLineMatcher().hasProlog("neo.sh deploy-mta") .hasSingleQuotedOption('host', 'configuration-frwk\\.deploy\\.host\\.com') .hasSingleQuotedOption('account', 'configurationFrwkUser123') .hasOption('synchronous', '') @@ -148,7 +147,7 @@ class NeoDeployTest extends BasePiperTest { stepRule.step.neoDeploy(script: nullScript) Assert.assertThat(shellRule.shell, - new CommandLineMatcher().hasProlog("\"/opt/neo/tools/neo.sh\" deploy-mta") + new CommandLineMatcher().hasProlog("neo.sh deploy-mta") .hasSingleQuotedOption('source', 'archive.mtar')) } @@ -159,7 +158,7 @@ class NeoDeployTest extends BasePiperTest { source: "archive.mtar") Assert.assertThat(shellRule.shell, - new CommandLineMatcher().hasProlog("\"/opt/neo/tools/neo.sh\" deploy-mta") + new CommandLineMatcher().hasProlog("neo.sh deploy-mta") .hasSingleQuotedOption('source', 'archive.mtar')) } @@ -184,7 +183,7 @@ class NeoDeployTest extends BasePiperTest { ) Assert.assertThat(shellRule.shell, - new CommandLineMatcher().hasProlog("\"/opt/neo/tools/neo.sh\" deploy-mta") + new CommandLineMatcher().hasProlog("neo.sh deploy-mta") .hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com') .hasSingleQuotedOption('account', 'trialuser123') .hasOption('synchronous', '') @@ -194,69 +193,6 @@ class NeoDeployTest extends BasePiperTest { ) } - - @Test - void neoHomeNotSetTest() { - - mockHomeVariablesNotSet() - - stepRule.step.neoDeploy(script: nullScript, - source: archiveName - ) - - assert shellRule.shell.find { c -> c.contains('"neo.sh" deploy-mta') } - assert loggingRule.log.contains('SAP Cloud Platform Console Client is on PATH.') - assert loggingRule.log.contains("Using SAP Cloud Platform Console Client 'neo.sh'.") - } - - - @Test - void neoHomeAsParameterTest() { - - mockHomeVariablesNotSet() - - stepRule.step.neoDeploy(script: nullScript, - source: archiveName, - neo:[credentialsId: 'myCredentialsId'], - neoHome: '/param/neo' - ) - - assert shellRule.shell.find { c -> c = "\"/param/neo/tools/neo.sh\" deploy-mta" } - assert loggingRule.log.contains("SAP Cloud Platform Console Client home '/param/neo' retrieved from configuration.") - assert loggingRule.log.contains("Using SAP Cloud Platform Console Client '/param/neo/tools/neo.sh'.") - } - - - @Test - void neoHomeFromEnvironmentTest() { - - stepRule.step.neoDeploy(script: nullScript, - source: archiveName - ) - - assert shellRule.shell.find { c -> c.contains("\"/opt/neo/tools/neo.sh\" deploy-mta") } - assert loggingRule.log.contains("SAP Cloud Platform Console Client home '/opt/neo' retrieved from environment.") - assert loggingRule.log.contains("Using SAP Cloud Platform Console Client '/opt/neo/tools/neo.sh'.") - } - - - @Test - void neoHomeFromCustomStepConfigurationTest() { - - mockHomeVariablesNotSet() - - nullScript.commonPipelineEnvironment.configuration = [steps: [neoDeploy: [neo: [host: 'test.deploy.host.com', account: 'trialuser123'], neoHome: '/config/neo']]] - - stepRule.step.neoDeploy(script: nullScript, - source: archiveName - ) - - assert shellRule.shell.find { c -> c = "\"/config/neo/tools/neo.sh\" deploy-mta" } - assert loggingRule.log.contains("SAP Cloud Platform Console Client home '/config/neo' retrieved from configuration.") - assert loggingRule.log.contains("Using SAP Cloud Platform Console Client '/config/neo/tools/neo.sh'.") - } - - @Test void archiveNotProvidedTest() { @@ -294,7 +230,7 @@ class NeoDeployTest extends BasePiperTest { stepRule.step.neoDeploy(script: nullScript, source: archiveName, deployMode: 'mta') Assert.assertThat(shellRule.shell, - new CommandLineMatcher().hasProlog("\"/opt/neo/tools/neo.sh\" deploy-mta") + new CommandLineMatcher().hasProlog("neo.sh deploy-mta") .hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com') .hasSingleQuotedOption('account', 'trialuser123') .hasOption('synchronous', '') @@ -319,7 +255,7 @@ class NeoDeployTest extends BasePiperTest { source: warArchiveName) Assert.assertThat(shellRule.shell, - new CommandLineMatcher().hasProlog("\"/opt/neo/tools/neo.sh\" deploy") + new CommandLineMatcher().hasProlog("neo.sh deploy") .hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com') .hasSingleQuotedOption('account', 'trialuser123') .hasSingleQuotedOption('application', 'testApp') @@ -350,7 +286,7 @@ class NeoDeployTest extends BasePiperTest { ) Assert.assertThat(shellRule.shell, - new CommandLineMatcher().hasProlog("\"/opt/neo/tools/neo.sh\" rolling-update") + new CommandLineMatcher().hasProlog("neo.sh rolling-update") .hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com') .hasSingleQuotedOption('account', 'trialuser123') .hasSingleQuotedOption('application', 'testApp') @@ -380,7 +316,7 @@ class NeoDeployTest extends BasePiperTest { Assert.assertThat(shellRule.shell, new CommandLineMatcher() - .hasProlog("\"/opt/neo/tools/neo.sh\" deploy") + .hasProlog("neo.sh deploy") .hasSingleQuotedOption('application', 'testApp')) } @@ -443,7 +379,7 @@ class NeoDeployTest extends BasePiperTest { ) Assert.assertThat(shellRule.shell, - new CommandLineMatcher().hasProlog("\"/opt/neo/tools/neo.sh\" deploy") + new CommandLineMatcher().hasProlog("neo.sh deploy") .hasArgument("config.properties") .hasSingleQuotedOption('user', 'defaultUser') .hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*') @@ -468,7 +404,7 @@ class NeoDeployTest extends BasePiperTest { ]) Assert.assertThat(shellRule.shell, - new CommandLineMatcher().hasProlog("\"/opt/neo/tools/neo.sh\" rolling-update") + new CommandLineMatcher().hasProlog("neo.sh rolling-update") .hasArgument('config.properties') .hasSingleQuotedOption('user', 'defaultUser') .hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*') @@ -556,28 +492,4 @@ class NeoDeployTest extends BasePiperTest { size: 'lite' ]) } - - private mockShellCommands() { - String javaVersion = '''openjdk version \"1.8.0_121\" - OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-1~bpo8+1-b13) - OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)''' - shellRule.setReturnValue(Type.REGEX, '.*java -version.*', javaVersion) - - String neoVersion = '''SAP Cloud Platform Console Client - SDK version : 3.39.10 - Runtime : neo-java-web''' - shellRule.setReturnValue(Type.REGEX, '.*neo.sh version.*', neoVersion) - - shellRule.setReturnValue(Type.REGEX, '.*JAVA_HOME.*', '/opt/java') - shellRule.setReturnValue(Type.REGEX, '.*NEO_HOME.*', '/opt/neo') - shellRule.setReturnValue(Type.REGEX, '.*which java.*', 0) - shellRule.setReturnValue(Type.REGEX, '.*which neo.*', 0) - } - - private mockHomeVariablesNotSet() { - shellRule.setReturnValue(Type.REGEX, '.*JAVA_HOME.*', '') - shellRule.setReturnValue(Type.REGEX, '.*NEO_HOME.*', '') - shellRule.setReturnValue(Type.REGEX, '.*which java.*', 0) - shellRule.setReturnValue(Type.REGEX, '.*which neo.*', 0) - } } diff --git a/test/groovy/com/sap/piper/tools/neo/NeoCommandHelperTest.groovy b/test/groovy/com/sap/piper/tools/neo/NeoCommandHelperTest.groovy index ad54ebc05..d272c24cd 100644 --- a/test/groovy/com/sap/piper/tools/neo/NeoCommandHelperTest.groovy +++ b/test/groovy/com/sap/piper/tools/neo/NeoCommandHelperTest.groovy @@ -34,7 +34,6 @@ class NeoCommandHelperTest extends BasePiperTest { String source = (deployMode == DeployMode.MTA) ? 'file.mta' : 'file.war' String username = 'username' String password = 'password' - String neoExecutable = '/path/tools/neo.sh'; nullScript.STEP_NAME="neoDeploy" @@ -42,7 +41,6 @@ class NeoCommandHelperTest extends BasePiperTest { nullScript, deployMode, deploymentConfiguration, - neoExecutable, username, password, source @@ -52,7 +50,7 @@ class NeoCommandHelperTest extends BasePiperTest { @Test void testStatusCommand() { String actual = getTestFixture(DeployMode.WAR_PARAMS).statusCommand() - String expected = "\"/path/tools/neo.sh\" status --host 'host_value' --account 'account_value' " + + String expected = "neo.sh status --host 'host_value' --account 'account_value' " + "--application 'application_value' --user 'username' --password 'password'" Assert.assertEquals(expected, actual) } @@ -60,14 +58,14 @@ class NeoCommandHelperTest extends BasePiperTest { @Test void testStatusCommandForProperties() { String actual = getTestFixture(DeployMode.WAR_PROPERTIES_FILE).statusCommand() - String expected = "\"/path/tools/neo.sh\" status file.properties --user 'username' --password 'password'" + String expected = "neo.sh status file.properties --user 'username' --password 'password'" Assert.assertEquals(expected, actual) } @Test void testRollingUpdateCommand() { String actual = getTestFixture(DeployMode.WAR_PARAMS).rollingUpdateCommand() - String basicCommand = "\"/path/tools/neo.sh\" rolling-update --host 'host_value' --account 'account_value' " + + String basicCommand = "neo.sh rolling-update --host 'host_value' --account 'account_value' " + "--application 'application_value' --user 'username' --password 'password' --source 'file.war'" Assert.assertTrue(actual.contains(basicCommand)) @@ -81,14 +79,14 @@ class NeoCommandHelperTest extends BasePiperTest { @Test void testRollingUpdateCommandForProperties() { String actual = getTestFixture(DeployMode.WAR_PROPERTIES_FILE).rollingUpdateCommand() - String expected = "\"/path/tools/neo.sh\" rolling-update file.properties --user 'username' --password 'password' --source 'file.war' " + String expected = "neo.sh rolling-update file.properties --user 'username' --password 'password' --source 'file.war' " Assert.assertEquals(expected, actual) } @Test void testDeployCommand() { String actual = getTestFixture(DeployMode.WAR_PARAMS).deployCommand() - String basicCommand = "\"/path/tools/neo.sh\" deploy --host 'host_value' --account 'account_value' " + + String basicCommand = "neo.sh deploy --host 'host_value' --account 'account_value' " + "--application 'application_value' --user 'username' --password 'password' --source 'file.war'" Assert.assertTrue(actual.contains(basicCommand)) @@ -102,14 +100,14 @@ class NeoCommandHelperTest extends BasePiperTest { @Test void testDeployCommandForProperties() { String actual = getTestFixture(DeployMode.WAR_PROPERTIES_FILE).deployCommand() - String expected = "\"/path/tools/neo.sh\" deploy file.properties --user 'username' --password 'password' --source 'file.war' " + String expected = "neo.sh deploy file.properties --user 'username' --password 'password' --source 'file.war' " Assert.assertEquals(expected, actual) } @Test void testRestartCommand() { String actual = getTestFixture(DeployMode.WAR_PARAMS).restartCommand() - String expected = "\"/path/tools/neo.sh\" restart --synchronous --host 'host_value' --account 'account_value' " + + String expected = "neo.sh restart --synchronous --host 'host_value' --account 'account_value' " + "--application 'application_value' --user 'username' --password 'password'" Assert.assertEquals(expected, actual) } @@ -117,14 +115,14 @@ class NeoCommandHelperTest extends BasePiperTest { @Test void testRestartCommandForProperties() { String actual = getTestFixture(DeployMode.WAR_PROPERTIES_FILE).restartCommand() - String expected = "\"/path/tools/neo.sh\" restart --synchronous file.properties --user 'username' --password 'password'" + String expected = "neo.sh restart --synchronous file.properties --user 'username' --password 'password'" Assert.assertEquals(expected, actual) } @Test void deployMta() { String actual = getTestFixture(DeployMode.MTA).deployMta() - String expected = "\"/path/tools/neo.sh\" deploy-mta --synchronous --host 'host_value' --account 'account_value' " + + String expected = "neo.sh deploy-mta --synchronous --host 'host_value' --account 'account_value' " + "--user 'username' --password 'password' --source 'file.mta'" Assert.assertEquals(expected, actual) } diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index e4a373fae..160a7184c 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -1,6 +1,5 @@ import com.sap.piper.ConfigurationHelper import com.sap.piper.Utils -import com.sap.piper.tools.ToolDescriptor import com.sap.piper.tools.neo.DeployMode import com.sap.piper.tools.neo.NeoCommandHelper import com.sap.piper.tools.neo.WarAction @@ -57,9 +56,6 @@ void call(parameters = [:]) { stepParam3: parameters?.script == null, ], configuration) - ToolDescriptor neo = new ToolDescriptor('SAP Cloud Platform Console Client', 'NEO_HOME', 'neoHome', '/tools/', 'neo.sh', null, 'version') - ToolDescriptor java = new ToolDescriptor('Java', 'JAVA_HOME', '', '/bin/', 'java', '1.8.0', '-version 2>&1') - if (configuration.neo.credentialsId) { withCredentials([usernamePassword( credentialsId: configuration.neo.credentialsId, @@ -75,18 +71,12 @@ void call(parameters = [:]) { dockerOptions: configuration.dockerOptions ) { - neo.verify(this, configuration) - java.verify(this, configuration) - - String neoExecutable = neo.getToolExecutable(script, configuration) - DeployMode deployMode = DeployMode.fromString(configuration.deployMode) NeoCommandHelper neoCommandHelper = new NeoCommandHelper( this, deployMode, configuration.neo, - neoExecutable, NEO_USERNAME, NEO_PASSWORD, configuration.source