mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
Merge branch 'master' into CCFenner-patch-2
This commit is contained in:
commit
2c2700f10a
@ -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
|
||||
}
|
||||
|
@ -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}
|
||||
"""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user