1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-02-07 13:42:23 +02:00

fix(mta): create MTAR in project root when using Cloud MBT (#1024)

* fix(mta): generate MTAR to the project root when Cloud MBT is used

fixes #1023

* add test case
This commit is contained in:
Christopher Fenner 2019-12-04 13:24:23 +01:00 committed by GitHub
parent 8bdd800a6d
commit 1b95951eb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 13 deletions

View File

@ -16,6 +16,10 @@ import util.JenkinsStepRule
import util.JenkinsWriteFileRule
import util.Rules
import static org.junit.Assert.assertThat
import static org.hamcrest.Matchers.containsString
import static org.hamcrest.Matchers.hasItem
public class MtaBuildTest extends BasePiperTest {
private ExpectedException thrown = new ExpectedException()
@ -54,7 +58,6 @@ public class MtaBuildTest extends BasePiperTest {
}
@Test
void environmentPathTest() {
@ -63,7 +66,6 @@ public class MtaBuildTest extends BasePiperTest {
assert shellRule.shell.find { c -> c.contains('PATH=./node_modules/.bin:$PATH')}
}
@Test
void sedTest() {
@ -72,7 +74,6 @@ public class MtaBuildTest extends BasePiperTest {
assert shellRule.shell.find { c -> c =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" "mta.yaml"$/}
}
@Test
void mtarFilePathFromCommonPipelineEnvironmentTest() {
@ -92,7 +93,6 @@ public class MtaBuildTest extends BasePiperTest {
assert shellRule.shell.find { c -> c.contains('-jar /mylocation/mta/mta.jar --mtar')}
}
@Test
void noMtaPresentTest() {
helper.registerAllowedMethod('fileExists', [String], { false })
@ -103,7 +103,6 @@ public class MtaBuildTest extends BasePiperTest {
stepRule.step.mtaBuild(script: nullScript, buildTarget: 'NEO')
}
@Test
void badMtaTest() {
@ -115,7 +114,6 @@ public class MtaBuildTest extends BasePiperTest {
stepRule.step.mtaBuild(script: nullScript, buildTarget: 'NEO')
}
@Test
void noIdInMtaTest() {
@ -127,7 +125,6 @@ public class MtaBuildTest extends BasePiperTest {
stepRule.step.mtaBuild(script: nullScript, buildTarget: 'NEO')
}
@Test
void mtaJarLocationFromCustomStepConfigurationTest() {
@ -139,7 +136,6 @@ public class MtaBuildTest extends BasePiperTest {
assert shellRule.shell.find(){ c -> c.contains('java -jar /config/mta/mta.jar --mtar')}
}
@Test
void mtaJarLocationFromDefaultStepConfigurationTest() {
@ -149,7 +145,6 @@ public class MtaBuildTest extends BasePiperTest {
assert shellRule.shell.find(){ c -> c.contains('java -jar /opt/sap/mta/lib/mta.jar --mtar')}
}
@Test
void buildTargetFromParametersTest() {
@ -158,7 +153,6 @@ public class MtaBuildTest extends BasePiperTest {
assert shellRule.shell.find { c -> c.contains('java -jar /opt/sap/mta/lib/mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO build')}
}
@Test
void buildTargetFromCustomStepConfigurationTest() {
@ -258,7 +252,6 @@ public class MtaBuildTest extends BasePiperTest {
assert shellRule.shell.find { c -> c.contains('java -jar /opt/sap/mta/lib/mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO build')}
}
@Test
void extensionFromParametersTest() {
@ -267,7 +260,6 @@ public class MtaBuildTest extends BasePiperTest {
assert shellRule.shell.find { c -> c.contains('java -jar /opt/sap/mta/lib/mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO --extension=param_extension build')}
}
@Test
void extensionFromCustomStepConfigurationTest() {
@ -278,6 +270,17 @@ public class MtaBuildTest extends BasePiperTest {
assert shellRule.shell.find(){ c -> c.contains('java -jar /opt/sap/mta/lib/mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO --extension=config_extension build')}
}
@Test
void testCloudMbt() {
nullScript.commonPipelineEnvironment.configuration = [steps:[mtaBuild:[mtaBuildTool: 'cloudMbt']]]
stepRule.step.mtaBuild(script: nullScript)
assertThat(shellRule.shell, hasItem(containsString('mbt build')))
assertThat(shellRule.shell, hasItem(containsString('--platform cf')))
assertThat(shellRule.shell, hasItem(containsString('--target ./')))
assertThat(shellRule.shell, hasItem(containsString('--mtar com.mycompany.northwind.mtar')))
}
private static defaultMtaYaml() {
return '''

View File

@ -133,7 +133,6 @@ void call(Map parameters = [:]) {
def options = []
options.push("--mtar ${id}.mtar")
switch(configuration.mtaBuildTool) {
case 'classic':
// If it is not configured, it is expected on the PATH
@ -144,6 +143,7 @@ void call(Map parameters = [:]) {
break
case 'cloudMbt':
options.push("--platform ${configuration.platform}")
options.push("--target ./")
if (configuration.extension) options.push("--extensions=${configuration.extension}")
mtaCall = "mbt build ${options.join(' ')}"
break