1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00

Use dockerExecute inside neoDeploy

This commit is contained in:
Marcus Holl 2017-12-13 10:05:19 +01:00
parent b843ac0794
commit bc2fb93551
2 changed files with 47 additions and 39 deletions

View File

@ -47,6 +47,7 @@ class NeoDeploymentTest extends BasePipelineTest {
propertiesFileName = 'config.properties' propertiesFileName = 'config.properties'
archiveName = "archive.mtar" archiveName = "archive.mtar"
helper.registerAllowedMethod('dockerExecute', [Map, Closure], null)
helper.registerAllowedMethod('error', [String], { s -> throw new AbortException(s) }) helper.registerAllowedMethod('error', [String], { s -> throw new AbortException(s) })
helper.registerAllowedMethod('fileExists', [String], { s -> return new File(workspacePath, s).exists() }) helper.registerAllowedMethod('fileExists', [String], { s -> return new File(workspacePath, s).exists() })
helper.registerAllowedMethod('usernamePassword', [Map], { m -> return m }) helper.registerAllowedMethod('usernamePassword', [Map], { m -> return m })
@ -91,7 +92,7 @@ class NeoDeploymentTest extends BasePipelineTest {
neoCredentialsId: 'myCredentialsId' 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.") 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' 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.") 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' 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.") 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 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.") 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 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.") assert jlr.log.contains("Using Neo executable from PATH.")
} }
@ -217,7 +218,7 @@ class NeoDeploymentTest extends BasePipelineTest {
neoHome: '/etc/neo' 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') 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.") 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', warAction: 'deploy',
archivePath: warArchiveName) 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.") 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', warAction: 'rolling-update',
vmSize: 'lite') 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.") 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', warAction: 'deploy',
vmSize: 'lite') 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.") 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', warAction: 'rolling-update',
vmSize: 'lite') 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.") assert jlr.log.contains("[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment.")
} }

View File

@ -133,6 +133,36 @@ def call(parameters = [:]) {
def neoExecutable = getNeoExecutable(configuration) 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( withCredentials([usernamePassword(
credentialsId: credentialsId, credentialsId: credentialsId,
passwordVariable: 'password', passwordVariable: 'password',
@ -143,35 +173,12 @@ def call(parameters = [:]) {
--password '${password}' \ --password '${password}' \
--source "${archivePath}" \ --source "${archivePath}" \
""" """
dockerExecute(dockerImage: configuration.get('dockerImage'),
dockerEnvVars: configuration.get('dockerEnvVars'),
dockerOptions: configuration.get('dockerOptions')) {
if (deployMode == 'mta') { sh """${neoDeployScript} \
sh """#!/bin/bash ${commonDeployParams}
"${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}
""" """
} }
} }