From c04bc799766df4fdb4f68dcb9e051bca968fc0ef Mon Sep 17 00:00:00 2001 From: Alejandra Ferreiro Vidal Date: Tue, 17 Apr 2018 17:35:10 +0200 Subject: [PATCH] add extension to mtaBuild --- documentation/docs/steps/mtaBuild.md | 3 +++ test/groovy/MTABuildTest.groovy | 20 ++++++++++++++++++++ vars/mtaBuild.groovy | 9 ++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/documentation/docs/steps/mtaBuild.md b/documentation/docs/steps/mtaBuild.md index b9684804e..5f702bb07 100644 --- a/documentation/docs/steps/mtaBuild.md +++ b/documentation/docs/steps/mtaBuild.md @@ -17,11 +17,13 @@ Note that a version is formed by `major.minor.patch`, and a version is compatibl | -----------------|-----------|--------------------------------------------------------|--------------------| | `script` | yes | | | | `buildTarget` | yes | `'NEO'` | 'CF', 'NEO', 'XSA' | +| `extension` | no | | | | `mtaJarLocation` | no | | | | `applicationName`| no | | | * `script` - The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the `this` parameter, as in `script: this`. This allows the function to access the [`commonPipelineEnvironment`](commonPipelineEnvironment.md) for retrieving, for example, configuration parameters. * `buildTarget` - The target platform to which the mtar can be deployed. +* `extension` - The path to the extension descriptor file. * `mtaJarLocation` - The path of the `mta.jar` file. If no parameter is provided, the path is retrieved from the environment variables using the environment variable`MTA_JAR_LOCATION`. If no parameter and no environment variable is provided, the path is retrieved from the step configuration using the step configuration key `mtaJarLocation`. If the previous configurations are not provided, `mta.jar` is expected on the current working directory, and if it is not located on the current working directory an AbortException is thrown. * `applicationName` - The name of the application which is being built. If the parameter has been provided and no `mta.yaml` exists, the `mta.yaml` will be automatically generated using this parameter and the information (`name` and `version`) from `package.json` before the actual build starts. @@ -29,6 +31,7 @@ Note that a version is formed by `major.minor.patch`, and a version is compatibl The following parameters can also be specified as step parameters using the global configuration file: * `buildTarget` +* `extension` * `mtaJarLocation` * `applicationName` diff --git a/test/groovy/MTABuildTest.groovy b/test/groovy/MTABuildTest.groovy index 5685dcb6b..dc58a33db 100644 --- a/test/groovy/MTABuildTest.groovy +++ b/test/groovy/MTABuildTest.groovy @@ -237,6 +237,26 @@ public class MtaBuildTest extends BasePipelineTest { } + @Test + void extensionFromParametersTest() { + + jsr.step.call(buildTarget: 'NEO', extension: 'param_extension') + + assert jscr.shell.find { c -> c.contains('java -jar mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO --extension=param_extension build')} + } + + + @Test + void extensionFromCustomStepConfigurationTest() { + + jer.env.configuration = [steps:[mtaBuild:[buildTarget: 'NEO', extension: 'config_extension']]] + + jsr.step.call(script: [commonPipelineEnvironment: jer.env]) + + assert jscr.shell.find(){ c -> c.contains('java -jar mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO --extension=config_extension build')} + } + + private static defaultMtaYaml() { return ''' _schema-version: "2.0.0" diff --git a/vars/mtaBuild.groovy b/vars/mtaBuild.groovy index 66fc45c6a..c80e9e7c8 100644 --- a/vars/mtaBuild.groovy +++ b/vars/mtaBuild.groovy @@ -11,12 +11,14 @@ def call(Map parameters = [:]) { Set parameterKeys = [ 'applicationName', 'buildTarget', + 'extension', 'mtaJarLocation' ] Set stepConfigurationKeys = [ 'applicationName', 'buildTarget', + 'extension', 'mtaJarLocation' ] @@ -63,9 +65,14 @@ def call(Map parameters = [:]) { def mtaJar = mta.getToolExecutable(this, configuration) def buildTarget = configuration.buildTarget + def mtaCall = "${mtaJar} --mtar ${mtarFileName} --build-target=${buildTarget}" + + if (configuration.extension) mtaCall += " --extension=$configuration.extension" + mtaCall += ' build' + sh """#!/bin/bash export PATH=./node_modules/.bin:${PATH} - ${mtaJar} --mtar ${mtarFileName} --build-target=${buildTarget} build + $mtaCall """ def mtarFilePath = "${pwd()}/${mtarFileName}"