1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

Merge pull request #233 from marcusholl/fix/rolebackNeoDeployChange

Revert "remove the tool descriptor from neo deploy"
This commit is contained in:
Marcus Holl 2018-07-31 16:57:16 +02:00 committed by GitHub
commit 2db2a2944e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 95 additions and 18 deletions

View File

@ -100,7 +100,7 @@ class NeoDeployTest extends BasePiperTest {
)
Assert.assertThat(jscr.shell,
new CommandLineMatcher().hasProlog("#!/bin/bash neo.sh deploy-mta")
new CommandLineMatcher().hasProlog("#!/bin/bash \"/opt/neo/tools/neo.sh\" deploy-mta")
.hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com')
.hasSingleQuotedOption('account', 'trialuser123')
.hasOption('synchronous', '')
@ -118,7 +118,7 @@ class NeoDeployTest extends BasePiperTest {
)
Assert.assertThat(jscr.shell,
new CommandLineMatcher().hasProlog("#!/bin/bash neo.sh deploy-mta")
new CommandLineMatcher().hasProlog("#!/bin/bash \"/opt/neo/tools/neo.sh\" deploy-mta")
.hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com')
.hasSingleQuotedOption('account', 'trialuser123')
.hasOption('synchronous', '')
@ -142,7 +142,7 @@ class NeoDeployTest extends BasePiperTest {
)
Assert.assertThat(jscr.shell,
new CommandLineMatcher().hasProlog("#!/bin/bash neo.sh deploy-mta")
new CommandLineMatcher().hasProlog("#!/bin/bash \"/opt/neo/tools/neo.sh\" deploy-mta")
.hasSingleQuotedOption('host', 'configuration-frwk\\.deploy\\.host\\.com')
.hasSingleQuotedOption('account', 'configurationFrwkUser123')
.hasOption('synchronous', '')
@ -173,7 +173,7 @@ class NeoDeployTest extends BasePiperTest {
)
Assert.assertThat(jscr.shell,
new CommandLineMatcher().hasProlog("#!/bin/bash neo.sh deploy-mta")
new CommandLineMatcher().hasProlog("#!/bin/bash \"/opt/neo/tools/neo.sh\" deploy-mta")
.hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com')
.hasSingleQuotedOption('account', 'trialuser123')
.hasOption('synchronous', '')
@ -183,6 +183,68 @@ class NeoDeployTest extends BasePiperTest {
}
@Test
void neoHomeNotSetTest() {
helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionWithPath(m) })
jsr.step.call(script: nullScript,
archivePath: archiveName
)
assert jscr.shell.find { c -> c.contains('"neo.sh" deploy-mta') }
assert jlr.log.contains('SAP Cloud Platform Console Client is on PATH.')
assert jlr.log.contains("Using SAP Cloud Platform Console Client 'neo.sh'.")
}
@Test
void neoHomeAsParameterTest() {
helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionWithPath(m) })
jsr.step.call(script: nullScript,
archivePath: archiveName,
neoCredentialsId: 'myCredentialsId',
neoHome: '/param/neo'
)
assert jscr.shell.find{ c -> c = "\"/param/neo/tools/neo.sh\" deploy-mta" }
assert jlr.log.contains("SAP Cloud Platform Console Client home '/param/neo' retrieved from configuration.")
assert jlr.log.contains("Using SAP Cloud Platform Console Client '/param/neo/tools/neo.sh'.")
}
@Test
void neoHomeFromEnvironmentTest() {
jsr.step.call(script: nullScript,
archivePath: archiveName
)
assert jscr.shell.find { c -> c.contains("\"/opt/neo/tools/neo.sh\" deploy-mta")}
assert jlr.log.contains("SAP Cloud Platform Console Client home '/opt/neo' retrieved from environment.")
assert jlr.log.contains("Using SAP Cloud Platform Console Client '/opt/neo/tools/neo.sh'.")
}
@Test
void neoHomeFromCustomStepConfigurationTest() {
helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionWithPath(m) })
nullScript.commonPipelineEnvironment.configuration = [steps:[neoDeploy: [host: 'test.deploy.host.com', account: 'trialuser123', neoHome: '/config/neo']]]
jsr.step.call(script: nullScript,
archivePath: archiveName
)
assert jscr.shell.find { c -> c = "\"/config/neo/tools/neo.sh\" deploy-mta"}
assert jlr.log.contains("SAP Cloud Platform Console Client home '/config/neo' retrieved from configuration.")
assert jlr.log.contains("Using SAP Cloud Platform Console Client '/config/neo/tools/neo.sh'.")
}
@Test
void archiveNotProvidedTest() {
@ -221,7 +283,7 @@ class NeoDeployTest extends BasePiperTest {
jsr.step.call(script: nullScript, archivePath: archiveName, deployMode: 'mta')
Assert.assertThat(jscr.shell,
new CommandLineMatcher().hasProlog("#!/bin/bash neo.sh deploy-mta")
new CommandLineMatcher().hasProlog("#!/bin/bash \"/opt/neo/tools/neo.sh\" deploy-mta")
.hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com')
.hasSingleQuotedOption('account', 'trialuser123')
.hasOption('synchronous', '')
@ -244,7 +306,7 @@ class NeoDeployTest extends BasePiperTest {
archivePath: warArchiveName)
Assert.assertThat(jscr.shell,
new CommandLineMatcher().hasProlog("#!/bin/bash neo.sh deploy")
new CommandLineMatcher().hasProlog("#!/bin/bash \"/opt/neo/tools/neo.sh\" deploy")
.hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com')
.hasSingleQuotedOption('account', 'trialuser123')
.hasSingleQuotedOption('application', 'testApp')
@ -270,7 +332,7 @@ class NeoDeployTest extends BasePiperTest {
vmSize: 'lite')
Assert.assertThat(jscr.shell,
new CommandLineMatcher().hasProlog("#!/bin/bash neo.sh rolling-update")
new CommandLineMatcher().hasProlog("#!/bin/bash \"/opt/neo/tools/neo.sh\" rolling-update")
.hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com')
.hasSingleQuotedOption('account', 'trialuser123')
.hasSingleQuotedOption('application', 'testApp')
@ -296,7 +358,7 @@ class NeoDeployTest extends BasePiperTest {
vmSize: 'lite')
Assert.assertThat(jscr.shell,
new CommandLineMatcher().hasProlog("#!/bin/bash neo.sh deploy")
new CommandLineMatcher().hasProlog("#!/bin/bash \"/opt/neo/tools/neo.sh\" deploy")
.hasArgument("config.properties")
.hasSingleQuotedOption('user', 'defaultUser')
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
@ -317,7 +379,7 @@ class NeoDeployTest extends BasePiperTest {
vmSize: 'lite')
Assert.assertThat(jscr.shell,
new CommandLineMatcher().hasProlog("#!/bin/bash neo.sh rolling-update")
new CommandLineMatcher().hasProlog("#!/bin/bash \"/opt/neo/tools/neo.sh\" rolling-update")
.hasArgument('config.properties')
.hasSingleQuotedOption('user', 'defaultUser')
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
@ -474,8 +536,12 @@ class NeoDeployTest extends BasePiperTest {
if(m.script.contains('JAVA_HOME')) {
return '/opt/java'
} else if(m.script.contains('NEO_HOME')) {
return '/opt/neo'
} else if (m.script.contains('which java')) {
return 0
} else if (m.script.contains('which neo')) {
return 0
} else {
return 0
}
@ -485,8 +551,12 @@ class NeoDeployTest extends BasePiperTest {
if(m.script.contains('JAVA_HOME')) {
return ''
} else if(m.script.contains('NEO_HOME')) {
return ''
} else if (m.script.contains('which java')) {
return 0
} else if (m.script.contains('which neo')) {
return 0
} else {
return 0
}

View File

@ -22,6 +22,7 @@ def call(parameters = [:]) {
'dockerOptions',
'host',
'neoCredentialsId',
'neoHome',
'propertiesFile',
'runtime',
'runtimeVersion',
@ -35,7 +36,8 @@ def call(parameters = [:]) {
'dockerImage',
'dockerOptions',
'host',
'neoCredentialsId'
'neoCredentialsId',
'neoHome'
]
handlePipelineStepErrors (stepName: stepName, stepParameters: parameters) {
@ -146,22 +148,26 @@ def call(parameters = [:]) {
deployAccount = utils.getMandatoryParameter(configuration, 'account')
}
def neoCmdArgs = """${warAction} \
def neo = new ToolDescriptor('SAP Cloud Platform Console Client', 'NEO_HOME', 'neoHome', '/tools/', 'neo.sh', null, 'version')
def neoExecutable = neo.getToolExecutable(this, configuration)
def neoDeployScript = """#!/bin/bash
"${neoExecutable}" ${warAction} \
--source "${archivePath}" \
"""
"""
if (deployMode in ['mta', 'warParams']) {
neoCmdArgs +=
neoDeployScript +=
"""--host '${deployHost}' \
--account '${deployAccount}' \
"""
}
if (deployMode == 'mta') {
neoCmdArgs += "--synchronous"
neoDeployScript += "--synchronous"
}
if (deployMode == 'warParams') {
neoCmdArgs +=
neoDeployScript +=
"""--application '${applicationName}' \
--runtime '${runtime}' \
--runtime-version '${runtimeVersion}' \
@ -169,7 +175,7 @@ def call(parameters = [:]) {
}
if (deployMode == 'warPropertiesFile') {
neoCmdArgs +=
neoDeployScript +=
"""${propertiesFile}"""
}
@ -186,11 +192,12 @@ def call(parameters = [:]) {
dockerEnvVars: configuration.get('dockerEnvVars'),
dockerOptions: configuration.get('dockerOptions')) {
neo.verify(this, configuration)
def java = new ToolDescriptor('Java', 'JAVA_HOME', '', '/bin/', 'java', '1.8.0', '-version 2>&1')
java.verify(this, configuration)
sh """#!/bin/bash
neo.sh ${neoCmdArgs} \
sh """${neoDeployScript} \
${credentials}
"""
}