diff --git a/test/groovy/NeoDeploymentTest.groovy b/test/groovy/NeoDeploymentTest.groovy index 1c67c6696..1bdde7623 100644 --- a/test/groovy/NeoDeploymentTest.groovy +++ b/test/groovy/NeoDeploymentTest.groovy @@ -47,6 +47,7 @@ class NeoDeploymentTest extends BasePipelineTest { propertiesFileName = 'config.properties' archiveName = "archive.mtar" + helper.registerAllowedMethod('dockerExecute', [Map, Closure], null) helper.registerAllowedMethod('error', [String], { s -> throw new AbortException(s) }) helper.registerAllowedMethod('fileExists', [String], { s -> return new File(workspacePath, s).exists() }) helper.registerAllowedMethod('usernamePassword', [Map], { m -> return m }) @@ -91,7 +92,7 @@ class NeoDeploymentTest extends BasePipelineTest { neoCredentialsId: 'myCredentialsId' ) - assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --user 'anonymous' --password '\*\*\*\*\*\*\*\*' --source ".*" --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous/ + assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous --user 'anonymous' --password '\*\*\*\*\*\*\*\*' --source ".*"/ assert jlr.log.contains("[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment.") @@ -112,7 +113,7 @@ class NeoDeploymentTest extends BasePipelineTest { neoCredentialsId: 'myCredentialsId' ) - assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --user 'anonymous' --password '\*\*\*\*\*\*\*\*' --source ".*" --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous/ + assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous --user 'anonymous' --password '\*\*\*\*\*\*\*\*' --source ".*"/ assert jlr.log.contains("[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment.") @@ -138,7 +139,7 @@ class NeoDeploymentTest extends BasePipelineTest { neoCredentialsId: 'myCredentialsId' ) - assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --user 'anonymous' --password '\*\*\*\*\*\*\*\*' --source ".*" --host 'configuration-frwk\.deploy\.host\.com' --account 'configurationFrwkUser123' --synchronous/ + assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --host 'configuration-frwk\.deploy\.host\.com' --account 'configurationFrwkUser123' --synchronous --user 'anonymous' --password '\*\*\*\*\*\*\*\*' --source ".*"/ assert jlr.log.contains("[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment.") @@ -179,7 +180,7 @@ class NeoDeploymentTest extends BasePipelineTest { archivePath: archiveName ) - assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*" --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous/ + assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*"/ assert jlr.log.contains("[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment.") } @@ -197,7 +198,7 @@ class NeoDeploymentTest extends BasePipelineTest { archivePath: archiveName ) - assert jscr.shell[0] =~ /#!\/bin\/bash "neo" deploy-mta --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*" --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous/ + assert jscr.shell[0] =~ /#!\/bin\/bash "neo" deploy-mta --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*"/ assert jlr.log.contains("Using Neo executable from PATH.") } @@ -217,7 +218,7 @@ class NeoDeploymentTest extends BasePipelineTest { neoHome: '/etc/neo' ) - assert jscr.shell[0] =~ /#!\/bin\/bash "\/etc\/neo\/tools\/neo\.sh" deploy-mta --user 'anonymous' --password '\*\*\*\*\*\*\*\*' --source ".*" --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous.*/ + assert jscr.shell[0] =~ /#!\/bin\/bash "\/etc\/neo\/tools\/neo\.sh" deploy-mta --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous --user 'anonymous' --password '\*\*\*\*\*\*\*\*' --source ".*"/ } @@ -270,7 +271,7 @@ class NeoDeploymentTest extends BasePipelineTest { neoDeployScript.call(script: [commonPipelineEnvironment: cpe], archivePath: archiveName, deployMode: 'mta') - assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*" --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous.*/ + assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy-mta --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*"/ assert jlr.log.contains("[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment.") } @@ -291,7 +292,7 @@ class NeoDeploymentTest extends BasePipelineTest { warAction: 'deploy', archivePath: warArchiveName) - assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war" --host 'test\.deploy\.host\.com' --account 'trialuser123' --application 'testApp' --runtime 'neo-javaee6-wp' --runtime-version '2\.125' --size 'lite'/ + assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy --host 'test\.deploy\.host\.com' --account 'trialuser123' --application 'testApp' --runtime 'neo-javaee6-wp' --runtime-version '2\.125' --size 'lite' --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war"/ assert jlr.log.contains("[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment.") } @@ -312,7 +313,7 @@ class NeoDeploymentTest extends BasePipelineTest { warAction: 'rolling-update', vmSize: 'lite') - assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" rolling-update --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war" --host 'test\.deploy\.host\.com' --account 'trialuser123' --application 'testApp' --runtime 'neo-javaee6-wp' --runtime-version '2\.125' --size 'lite'/ + assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" rolling-update --host 'test\.deploy\.host\.com' --account 'trialuser123' --application 'testApp' --runtime 'neo-javaee6-wp' --runtime-version '2\.125' --size 'lite' --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war"/ assert jlr.log.contains("[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment.") } @@ -332,7 +333,7 @@ class NeoDeploymentTest extends BasePipelineTest { warAction: 'deploy', vmSize: 'lite') - assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war" .*\.properties/ + assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" deploy .*\.properties --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war"/ assert jlr.log.contains("[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment.") } @@ -352,7 +353,7 @@ class NeoDeploymentTest extends BasePipelineTest { warAction: 'rolling-update', vmSize: 'lite') - assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" rolling-update --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war" .*\.properties/ + assert jscr.shell[0] =~ /#!\/bin\/bash "\/opt\/neo\/tools\/neo\.sh" rolling-update .*\.properties --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war"/ assert jlr.log.contains("[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment.") } diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index 6a79a4322..4d3d28dec 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -133,6 +133,36 @@ def call(parameters = [:]) { def neoExecutable = getNeoExecutable(configuration) + def neoDeployScript + + if (deployMode == 'mta') { + neoDeployScript = + """#!/bin/bash + "${neoExecutable}" deploy-mta \ + --host '${deployHost}' \ + --account '${deployAccount}' \ + --synchronous""" + } + + if (deployMode == 'warParams') { + neoDeployScript = + """#!/bin/bash + "${neoExecutable}" ${warAction} \ + --host '${deployHost}' \ + --account '${deployAccount}' \ + --application '${applicationName}' \ + --runtime '${runtime}' \ + --runtime-version '${runtimeVersion}' \ + --size '${vmSize}'""" + } + + if (deployMode == 'warPropertiesFile') { + neoDeployScript = + """#!/bin/bash + "${neoExecutable}" ${warAction} \ + ${propertiesFile}""" + } + withCredentials([usernamePassword( credentialsId: credentialsId, passwordVariable: 'password', @@ -143,35 +173,12 @@ def call(parameters = [:]) { --password '${password}' \ --source "${archivePath}" \ """ + dockerExecute(dockerImage: configuration.get('dockerImage'), + dockerEnvVars: configuration.get('dockerEnvVars'), + dockerOptions: configuration.get('dockerOptions')) { - if (deployMode == 'mta') { - sh """#!/bin/bash - "${neoExecutable}" deploy-mta \ - ${commonDeployParams} \ - --host '${deployHost}' \ - --account '${deployAccount}' \ - --synchronous - """ - } - - if (deployMode == 'warParams') { - sh """#!/bin/bash - "${neoExecutable}" ${warAction} \ - ${commonDeployParams} \ - --host '${deployHost}' \ - --account '${deployAccount}' \ - --application '${applicationName}' \ - --runtime '${runtime}' \ - --runtime-version '${runtimeVersion}' \ - --size '${vmSize}' - """ - } - - if (deployMode == 'warPropertiesFile') { - sh """#!/bin/bash - "${neoExecutable}" ${warAction} \ - ${commonDeployParams} \ - ${propertiesFile} + sh """${neoDeployScript} \ + ${commonDeployParams} """ } }