mirror of
https://github.com/SAP/jenkins-library.git
synced 2026-06-19 22:58:55 +02:00
More logging and be failfast around mtaYamlFile
- don't log a message and continue when it is clear that we cannot succeed
together with error raised later during attempt not parse a non-existing
file
- More log output in order to clarify what happens with mta.yaml
This commit is contained in:
@@ -40,7 +40,7 @@ public class MtaBuildTest extends BasePiperTest {
|
||||
@Before
|
||||
void init() {
|
||||
|
||||
helper.registerAllowedMethod('fileExists', [String], { s -> false })
|
||||
helper.registerAllowedMethod('fileExists', [String], { s -> s == 'mta.yaml' })
|
||||
helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionWithoutEnvVars(m) })
|
||||
|
||||
binding.setVariable('PATH', '/usr/bin')
|
||||
@@ -90,9 +90,10 @@ public class MtaBuildTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void noMtaPresentTest() {
|
||||
|
||||
jryr.registerYaml('mta.yaml', { throw new FileNotFoundException() })
|
||||
thrown.expect(FileNotFoundException)
|
||||
helper.registerAllowedMethod('fileExists', [String], { false })
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage('\'mta.yaml\' not found in project sources and \'applicationName\' not provided as parameter ' +
|
||||
'- cannot generate \'mta.yaml\' file.')
|
||||
|
||||
jsr.step.mtaBuild(script: nullScript, buildTarget: 'NEO')
|
||||
}
|
||||
|
||||
@@ -51,11 +51,14 @@ void call(Map parameters = [:]) {
|
||||
|
||||
if (!fileExists(mtaYamlName)) {
|
||||
if (!applicationName) {
|
||||
echo "'applicationName' not provided as parameter - will not try to generate ${mtaYamlName} file"
|
||||
error "'${mtaYamlName}' not found in project sources and 'applicationName' not provided as parameter - cannot generate '${mtaYamlName}' file."
|
||||
} else {
|
||||
echo "[INFO] '${mtaYamlName}' file not found in project sources, but application name provided as parameter - generating '${mtaYamlName}' file."
|
||||
MtaUtils mtaUtils = new MtaUtils(this)
|
||||
mtaUtils.generateMtaDescriptorFromPackageJson("package.json", mtaYamlName, applicationName)
|
||||
}
|
||||
} else {
|
||||
echo "[INFO] '${mtaYamlName}' file found in project sources."
|
||||
}
|
||||
|
||||
def mtaYaml = readYaml file: mtaYamlName
|
||||
|
||||
Reference in New Issue
Block a user