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

Merge remote-tracking branch 'github/master' into HEAD

This commit is contained in:
Marcus Holl 2018-09-21 13:27:29 +02:00
commit 9cd31e7236
45 changed files with 282 additions and 347 deletions

View File

@ -117,7 +117,7 @@ otherwise in the [LICENSE file][piper-library-license]
[piper-library-pages-plugins]: https://sap.github.io/jenkins-library/jenkins/requiredPlugins
[piper-library-issues]: https://github.com/SAP/jenkins-library/issues
[piper-library-license]: ./LICENSE
[piper-library-contribution]: ./CONTRIBUTING.md
[piper-library-contribution]: .github/CONTRIBUTING.md
[jenkins-doc-pipelines]: https://jenkins.io/solutions/pipeline
[jenkins-doc-libraries]: https://jenkins.io/doc/book/pipeline/shared-libraries
[jenkins-doc-steps]: https://jenkins.io/doc/pipeline/steps

View File

@ -8,20 +8,27 @@ Before doing this, validates that SAP Multitarget Application Archive Builder ex
Note that a version is formed by `major.minor.patch`, and a version is compatible to another version if the minor and patch versions are higher, but the major version is not, e.g. if 3.39.10 is the expected version, 3.39.11 and 3.40.1 would be compatible versions, but 4.0.1 would not be a compatible version.
## Prerequisites
* **SAP MTA Archive Builder 1.0.6 or compatible version** - can be downloaded from [SAP Development Tools](https://tools.hana.ondemand.com/#cloud).
* **Java 8 or compatible version** - necessary to run the `mta.jar` file.
* **NodeJS installed** - the MTA Builder uses `npm` to download node module dependencies such as `grunt`.
* A docker image meeting the following requirements
* **SAP MTA Archive Builder 1.0.6 or compatible version** - can be downloaded from [SAP Development Tools](https://tools.hana.ondemand.com/#cloud).
* **Java 8 or compatible version** - necessary to run the `mta.jar` file.
* **NodeJS installed** - the MTA Builder uses `npm` to download node module dependencies such as `grunt`.
## Parameters
| parameter | mandatory | default | possible values |
| -----------------|-----------|--------------------------------------------------------|--------------------|
| `script` | yes | | |
| `dockerImage` | yes | | |
| `dockerOptions` | no | '' | |
| `buildTarget` | yes | `'NEO'` | 'CF', 'NEO', 'XSA' |
| `extension` | no | | |
| `mtaJarLocation` | no | `'mta.jar'` | |
| `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.
* `dockerImage` - The Docker image to execute the MTA build.
A custom built image needs to include Multi-target Application Archive Builder.
Refer to [SAP Help Portal](https://help.sap.com/viewer/58746c584026430a890170ac4d87d03b/Cloud/en-US/ba7dd5a47b7a4858a652d15f9673c28d.html) for information on how to set it up.
* `dockerOptions` Docker options to be set when starting the container. It can be a list or a string.
* `buildTarget` - The target platform to which the mtar can be deployed.
* `extension` - The path to the extension descriptor file.
* `mtaJarLocation` - The location of the SAP Multitarget Application Archive Builder jar file, including file name and extension. First, the location is retrieved from the environment variables using the environment variable`MTA_JAR_LOCATION`. If no environment variable is provided, the location is retrieved from the parameters, or the step configuration using the key `mtaJarLocation`. If SAP Multitarget Application Archive Builder is not found on one of the previous locations an AbortException is thrown.
@ -31,6 +38,7 @@ Note that the environment variable `MTA_JAR_LOCATION` has priority. In case that
## Step configuration
The following parameters can also be specified as step parameters using the global configuration file:
* `dockerImage`
* `buildTarget`
* `extension`
* `mtaJarLocation`

View File

@ -1,5 +1,7 @@
package com.sap.piper
import com.cloudbees.groovy.cps.NonCPS
class ConfigurationHelper implements Serializable {
static ConfigurationHelper loadStepDefaults(Script step){
return new ConfigurationHelper(step)
@ -96,13 +98,19 @@ class ConfigurationHelper implements Serializable {
return this
}
Map use(){ return config }
@NonCPS // required because we have a closure in the
// method body that cannot be CPS transformed
Map use(){
MapUtils.traverse(config, { v -> (v instanceof GString) ? v.toString() : v })
return config
}
ConfigurationHelper(Map config = [:]){
this.config = config
}
def getConfigProperty(key) {
use()
return getConfigPropertyNested(config, key)
}

View File

@ -23,13 +23,4 @@ class ConfigurationMerger {
merged = merge(parameters, parameterKeys, merged)
return merged
}
@NonCPS
static Map merge(
def script, def stepName,
Map parameters, Set parameterKeys,
Set stepConfigurationKeys
) {
merge(script, stepName, parameters, parameterKeys, [:], stepConfigurationKeys)
}
}

View File

@ -38,4 +38,28 @@ class MapUtils implements Serializable {
return result
}
/**
* @param m The map to which the changed denoted by closure <code>strategy</code>
* should be applied.
* The strategy is also applied to all sub-maps contained as values
* in <code>m</code> in a recursive manner.
* @param strategy Strategy applied to all non-map entries
*/
@NonCPS
static void traverse(Map m, Closure strategy) {
def updates = [:]
for(def e : m.entrySet()) {
if(isMap(e.value)) {
traverse(e.getValue(), strategy)
}
else {
// do not update the map while it is traversed. Depending
// on the map implementation the behavior is undefined.
updates.put(e.getKey(), strategy(e.getValue()))
}
}
m.putAll(updates)
}
}

View File

@ -1,14 +1,19 @@
#!groovy
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain
import com.sap.piper.GitUtils
import util.BasePiperTest
import util.JenkinsDockerExecuteRule
import util.JenkinsEnvironmentRule
import util.JenkinsLoggingRule
import util.JenkinsReadMavenPomRule
import util.JenkinsReadYamlRule
import util.JenkinsShellCallRule
import util.JenkinsStepRule
import util.JenkinsWriteFileRule
@ -25,6 +30,16 @@ import static org.junit.Assert.assertEquals
class ArtifactSetVersionTest extends BasePiperTest {
Map dockerParameters
def GitUtils gitUtils = new GitUtils() {
boolean insideWorkTree() {
return true
}
String getGitCommitIdOrNull() {
return 'testCommitId'
}
}
def sshAgentList = []
private ExpectedException thrown = ExpectedException.none()
@ -38,6 +53,7 @@ class ArtifactSetVersionTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(thrown)
.around(jlr)
.around(jscr)
@ -59,10 +75,8 @@ class ArtifactSetVersionTest extends BasePiperTest {
return closure()
})
jscr.setReturnValue('git rev-parse HEAD', 'testCommitId')
jscr.setReturnValue("date --universal +'%Y%m%d%H%M%S'", '20180101010203')
jscr.setReturnValue('git diff --quiet HEAD', 0)
jscr.setReturnValue('git rev-parse --is-inside-work-tree 1>/dev/null 2>&1', 0)
helper.registerAllowedMethod('fileExists', [String.class], {true})
}
@ -76,8 +90,8 @@ class ArtifactSetVersionTest extends BasePiperTest {
assertThat(jscr.shell, hasItem("mvn --file 'pom.xml' --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn versions:set -DnewVersion=1.2.3-20180101010203_testCommitId -DgenerateBackupPoms=false"))
assertThat(jscr.shell, hasItem('git add .'))
assertThat(jscr.shell, hasItem("git commit -m 'update version 1.2.3-20180101010203_testCommitId'"))
assertThat(jscr.shell, hasItems(containsString('git tag build_1.2.3-20180101010203_testCommitId'),
assertThat(jscr.shell, hasItems(containsString("git commit -m 'update version 1.2.3-20180101010203_testCommitId'"),
containsString('git tag build_1.2.3-20180101010203_testCommitId'),
containsString('git push myGitSshUrl build_1.2.3-20180101010203_testCommitId')))
}
@ -101,7 +115,7 @@ class ArtifactSetVersionTest extends BasePiperTest {
void testVersioningCustomGitUserAndEMail() {
jsr.step.artifactSetVersion(script: jsr.step, juStabGitUtils: gitUtils, buildTool: 'maven', gitSshUrl: 'myGitSshUrl', gitUserEMail: 'test@test.com', gitUserName: 'test')
assertThat(jscr.shell, hasItem("git -c user.email=\"test@test.com\" -c user.name=\"test\" commit -m 'update version 1.2.3-20180101010203_testCommitId'"))
assertThat(jscr.shell, hasItem(containsString("git -c user.email=\"test@test.com\" -c user.name=\"test\" commit -m 'update version 1.2.3-20180101010203_testCommitId'")))
}
@Test
@ -142,11 +156,4 @@ class ArtifactSetVersionTest extends BasePiperTest {
)
assertThat(sshAgentList, hasItem('testCredentials'))
}
void prepareObjectInterceptors(object) {
object.metaClass.invokeMethod = helper.getMethodInterceptor()
object.metaClass.static.invokeMethod = helper.getMethodInterceptor()
object.metaClass.methodMissing = helper.getMethodMissingInterceptor()
}
}

View File

@ -20,6 +20,7 @@ class BatsExecuteTestsTest extends BasePiperTest {
@Rule
public RuleChain rules = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(thrown)
.around(jder)
.around(jscr)

View File

@ -1,5 +1,4 @@
import org.junit.After
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
@ -12,6 +11,7 @@ import com.sap.piper.cm.ChangeManagementException
import hudson.AbortException
import util.BasePiperTest
import util.JenkinsCredentialsRule
import util.JenkinsReadYamlRule
import util.JenkinsStepRule
import util.Rules
@ -23,6 +23,7 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(thrown)
.around(jsr)
.around(new JenkinsCredentialsRule(this)

View File

@ -1,3 +1,4 @@
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -9,9 +10,12 @@ import util.BasePiperTest
import static org.junit.Assert.assertEquals
import static org.junit.Assert.assertTrue
import util.Rules
import util.JenkinsReadYamlRule
import util.JenkinsStepRule
class ChecksPublishResultsTest extends BasePiperTest {
Map publisherStepOptions
List archiveStepPatterns
@ -21,6 +25,7 @@ class ChecksPublishResultsTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(jsr)
@Before

View File

@ -13,6 +13,7 @@ import util.JenkinsLoggingRule
import util.JenkinsShellCallRule
import util.JenkinsStepRule
import util.JenkinsWriteFileRule
import util.JenkinsReadYamlRule
import util.Rules
import static org.junit.Assert.assertThat
@ -30,10 +31,12 @@ class CloudFoundryDeployTest extends BasePiperTest {
private JenkinsDockerExecuteRule jedr = new JenkinsDockerExecuteRule(this)
private JenkinsStepRule jsr = new JenkinsStepRule(this)
private JenkinsEnvironmentRule jer = new JenkinsEnvironmentRule(this)
private JenkinsReadYamlRule jryr = new JenkinsReadYamlRule(this)
@Rule
public RuleChain rules = Rules
.getCommonRules(this)
.around(jryr)
.around(thrown)
.around(jlr)
.around(jscr)
@ -162,17 +165,7 @@ class CloudFoundryDeployTest extends BasePiperTest {
@Test
void testCfNativeAppNameFromManifest() {
helper.registerAllowedMethod('fileExists', [String.class], { s -> return true })
helper.registerAllowedMethod("readYaml", [Map], { Map m ->
if(m.text) {
return new Yaml().load(m.text)
} else if(m.file == 'test.yml') {
return [applications: [[name: 'manifestAppName']]]
} else if(m.file) {
return new Yaml().load((m.file as File).text)
} else {
throw new IllegalArgumentException("Key 'text' is missing in map ${m}.")
}
})
jryr.registerYaml('test.yml', "[applications: [[name: 'manifestAppName']]]")
jsr.step.cloudFoundryDeploy([
script: nullScript,
@ -191,18 +184,7 @@ class CloudFoundryDeployTest extends BasePiperTest {
@Test
void testCfNativeWithoutAppName() {
helper.registerAllowedMethod('fileExists', [String.class], { s -> return true })
helper.registerAllowedMethod("readYaml", [Map], { Map m ->
if(m.text) {
return new Yaml().load(m.text)
} else if(m.file == 'test.yml') {
return [applications: [[]]]
} else if(m.file) {
return new Yaml().load((m.file as File).text)
} else {
throw new IllegalArgumentException("Key 'text' is missing in map ${m}.")
}
})
jryr.registerYaml('test.yml', "applications: [[]]")
thrown.expect(hudson.AbortException)
thrown.expectMessage('[cloudFoundryDeploy] ERROR: No appName available in manifest test.yml.')

View File

@ -1,13 +1,16 @@
import com.sap.piper.JenkinsUtils
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain
import util.BasePiperTest
import util.JenkinsDockerExecuteRule
import util.JenkinsLoggingRule
import util.JenkinsReadYamlRule
import util.JenkinsShellCallRule
import util.JenkinsStepRule
import util.PluginMock
@ -27,6 +30,7 @@ class DockerExecuteOnKubernetesTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(exception)
.around(jder)
.around(jscr)

View File

@ -1,5 +1,6 @@
import com.sap.piper.k8s.ContainerMap
import com.sap.piper.JenkinsUtils
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -7,6 +8,7 @@ import org.junit.rules.RuleChain
import util.BasePiperTest
import util.JenkinsLoggingRule
import util.JenkinsReadYamlRule
import util.JenkinsStepRule
import util.PluginMock
import util.Rules
@ -23,6 +25,7 @@ class DockerExecuteTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(jlr)
.around(jsr)

View File

@ -1,4 +1,5 @@
#!groovy
import org.junit.Rule
import org.junit.Test
import util.BasePiperTest
@ -7,14 +8,17 @@ import static org.junit.Assert.assertTrue
import org.junit.rules.RuleChain
import util.Rules
import util.JenkinsReadYamlRule
import util.JenkinsStepRule
class DurationMeasureTest extends BasePiperTest {
private JenkinsStepRule jsr = new JenkinsStepRule(this)
@Rule
public RuleChain rules = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(jsr)
@Test

View File

@ -7,6 +7,7 @@ import org.junit.rules.RuleChain
import util.BasePiperTest
import util.JenkinsLoggingRule
import util.JenkinsStepRule
import util.JenkinsReadYamlRule
import util.Rules
import static org.junit.Assert.assertTrue
@ -19,6 +20,7 @@ class InfluxWriteDataTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(loggingRule)
.around(jsr)

View File

@ -1,8 +1,10 @@
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
import util.BasePiperTest
import util.JenkinsDockerExecuteRule
import util.JenkinsReadYamlRule
import util.JenkinsShellCallRule
import util.JenkinsStepRule
import util.Rules
@ -15,7 +17,6 @@ import static org.junit.Assert.assertEquals
import static org.junit.Assert.assertThat
import static org.junit.Assert.assertTrue
class MavenExecuteTest extends BasePiperTest {
Map dockerParameters
@ -27,6 +28,7 @@ class MavenExecuteTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(jder)
.around(jscr)
.around(jsr)

View File

@ -1,17 +1,16 @@
import org.junit.Before
import org.junit.BeforeClass
import org.junit.ClassRule
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain
import org.junit.rules.TemporaryFolder
import org.yaml.snakeyaml.parser.ParserException
import hudson.AbortException
import util.BasePiperTest
import util.JenkinsDockerExecuteRule
import util.JenkinsLoggingRule
import util.JenkinsReadYamlRule
import util.JenkinsShellCallRule
import util.JenkinsStepRule
import util.Rules
@ -21,42 +20,27 @@ public class MtaBuildTest extends BasePiperTest {
def toolMtaValidateCalled = false
def toolJavaValidateCalled = false
@ClassRule
public static TemporaryFolder tmp = new TemporaryFolder()
private ExpectedException thrown = new ExpectedException()
private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
private JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
private JenkinsDockerExecuteRule jder = new JenkinsDockerExecuteRule(this)
private JenkinsStepRule jsr = new JenkinsStepRule(this)
private JenkinsReadYamlRule jryr = new JenkinsReadYamlRule(this).registerYaml('mta.yaml', defaultMtaYaml() )
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(jryr)
.around(thrown)
.around(jlr)
.around(jscr)
.around(jder)
.around(jsr)
private static currentDir
private static newDir
private static mtaYaml
@BeforeClass
static void createTestFiles() {
currentDir = "${tmp.getRoot()}"
mtaYaml = tmp.newFile('mta.yaml')
newDir = "$currentDir/newDir"
tmp.newFolder('newDir')
tmp.newFile('newDir/mta.yaml') << defaultMtaYaml()
}
@Before
void init() {
mtaYaml.text = defaultMtaYaml()
helper.registerAllowedMethod('pwd', [], { currentDir } )
helper.registerAllowedMethod('fileExists', [GString.class], { false })
helper.registerAllowedMethod('fileExists', [String], { s -> false })
helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionWithoutEnvVars(m) })
binding.setVariable('PATH', '/usr/bin')
@ -77,7 +61,7 @@ public class MtaBuildTest extends BasePiperTest {
jsr.step.call(buildTarget: 'NEO')
assert jscr.shell.find { c -> c =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" ".*\/mta.yaml"$/}
assert jscr.shell.find { c -> c =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" "mta.yaml"$/}
}
@ -89,23 +73,9 @@ public class MtaBuildTest extends BasePiperTest {
def mtarFilePath = nullScript.commonPipelineEnvironment.getMtarFilePath()
assert mtarFilePath == "$currentDir/com.mycompany.northwind.mtar"
assert mtarFilePath == "com.mycompany.northwind.mtar"
}
@Test
void mtaBuildWithSurroundingDirTest() {
helper.registerAllowedMethod('pwd', [], { newDir } )
def mtarFilePath = jsr.step.call(buildTarget: 'NEO')
assert jscr.shell.find { c -> c =~ /sed -ie "s\/\\\$\{timestamp\}\/`date \+%Y%m%d%H%M%S`\/g" ".*\/newDir\/mta.yaml"$/}
assert mtarFilePath == "$newDir/com.mycompany.northwind.mtar"
}
@Test
void mtaJarLocationAsParameterTest() {
@ -121,7 +91,7 @@ public class MtaBuildTest extends BasePiperTest {
@Test
void noMtaPresentTest() {
mtaYaml.delete()
jryr.registerYaml('mta.yaml', { throw new FileNotFoundException() })
thrown.expect(FileNotFoundException)
jsr.step.call(buildTarget: 'NEO')
@ -134,7 +104,7 @@ public class MtaBuildTest extends BasePiperTest {
thrown.expect(ParserException)
thrown.expectMessage('while parsing a block mapping')
mtaYaml.text = badMtaYaml()
jryr.registerYaml('mta.yaml', badMtaYaml())
jsr.step.call(buildTarget: 'NEO')
}
@ -144,9 +114,9 @@ public class MtaBuildTest extends BasePiperTest {
void noIdInMtaTest() {
thrown.expect(AbortException)
thrown.expectMessage("Property 'ID' not found in mta.yaml file at: '")
thrown.expectMessage("Property 'ID' not found in mta.yaml file.")
mtaYaml.text = noIdMtaYaml()
jryr.registerYaml('mta.yaml', noIdMtaYaml() )
jsr.step.call(buildTarget: 'NEO')
}
@ -210,6 +180,21 @@ public class MtaBuildTest extends BasePiperTest {
assert jscr.shell.find(){ c -> c.contains('java -jar mta.jar --mtar com.mycompany.northwind.mtar --build-target=NEO build')}
}
@Test
void canConfigureDockerImage() {
jsr.step.call(script: nullScript, dockerImage: 'mta-docker-image:latest')
assert 'mta-docker-image:latest' == jder.dockerParams.dockerImage
}
@Test
void canConfigureDockerOptions() {
jsr.step.call(script: nullScript, dockerOptions: 'something')
assert 'something' == jder.dockerParams.dockerOptions
}
@Test
void buildTargetFromDefaultStepConfigurationTest() {

View File

@ -15,9 +15,11 @@ import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain
import util.BasePiperTest
import util.JenkinsCredentialsRule
import util.JenkinsLoggingRule
import util.JenkinsReadYamlRule
import util.JenkinsShellCallRule
import util.JenkinsStepRule
import util.Rules
@ -37,6 +39,7 @@ class NeoDeployTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(thrown)
.around(jlr)
.around(jscr)

View File

@ -12,6 +12,7 @@ import static org.junit.Assert.assertThat
import util.BasePiperTest
import util.JenkinsStepRule
import util.JenkinsLoggingRule
import util.JenkinsReadYamlRule
import util.JenkinsShellCallRule
import util.JenkinsDockerExecuteRule
import util.Rules
@ -27,6 +28,7 @@ class NewmanExecuteTest extends BasePiperTest {
@Rule
public RuleChain rules = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(thrown)
.around(jedr)
.around(jscr)

View File

@ -7,6 +7,7 @@ import org.junit.Test
import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain
import util.JenkinsReadYamlRule
import util.JenkinsStepRule
class PipelineExecuteTest extends BasePiperTest {
@ -16,6 +17,7 @@ class PipelineExecuteTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(thrown)
.around(jsr)

View File

@ -15,6 +15,7 @@ class PipelineStashFilesAfterBuildTest extends BasePiperTest {
@Rule
public RuleChain rules = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(jrj)
.around(jlr)
.around(jsr)

View File

@ -15,6 +15,7 @@ class PipelineStashFilesBeforeBuildTest extends BasePiperTest {
@Rule
public RuleChain rules = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
//.around(jrj)
.around(jlr)
.around(jscr)

View File

@ -3,13 +3,14 @@ import org.junit.Rule;
import org.junit.Test
import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain;
import com.sap.piper.DefaultValueCache
import util.BasePiperTest
import util.JenkinsLoggingRule
import util.JenkinsReadYamlRule
import util.JenkinsShellCallRule
import util.JenkinsStepRule;
import util.Rules
public class PrepareDefaultValuesTest extends BasePiperTest {
@ -21,6 +22,7 @@ public class PrepareDefaultValuesTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(thrown)
.around(jsr)
.around(jlr)
@ -52,11 +54,16 @@ public class PrepareDefaultValuesTest extends BasePiperTest {
@Test
public void testReInitializeOnCustomConfig() {
DefaultValueCache.createInstance([key:'value'])
def instance = DefaultValueCache.createInstance([key:'value'])
// existing instance is dropped in case a custom config is provided.
jsr.step.call(script: nullScript, customDefaults: 'custom.yml')
// this check is for checking we have another instance
assert ! instance.is(DefaultValueCache.getInstance())
// some additional checks that the configuration represented by the new
// config is fine
assert DefaultValueCache.getInstance().getDefaultValues().size() == 2
assert DefaultValueCache.getInstance().getDefaultValues().default == 'config'
assert DefaultValueCache.getInstance().getDefaultValues().custom == 'myConfig'
@ -65,10 +72,11 @@ public class PrepareDefaultValuesTest extends BasePiperTest {
@Test
public void testNoReInitializeWithoutCustomConfig() {
DefaultValueCache.createInstance([key:'value'])
def instance = DefaultValueCache.createInstance([key:'value'])
jsr.step.call(script: nullScript)
assert instance.is(DefaultValueCache.getInstance())
assert DefaultValueCache.getInstance().getDefaultValues().size() == 1
assert DefaultValueCache.getInstance().getDefaultValues().key == 'value'
}

View File

@ -6,11 +6,13 @@ import org.yaml.snakeyaml.Yaml
import util.BasePiperTest
import util.Rules
import util.JenkinsReadYamlRule
import util.JenkinsStepRule
import static org.junit.Assert.assertEquals
import static org.junit.Assert.assertNotNull
class SetupCommonPipelineEnvironmentTest extends BasePiperTest {
def usedConfigFile

View File

@ -11,6 +11,7 @@ import static org.junit.Assert.assertThat
import util.BasePiperTest
import util.JenkinsDockerExecuteRule
import util.JenkinsReadYamlRule
import util.JenkinsShellCallRule
import util.JenkinsStepRule
import util.JenkinsLoggingRule
@ -26,6 +27,7 @@ class SnykExecuteTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(thrown)
.around(jder)
.around(jscr)

View File

@ -5,8 +5,8 @@ import org.junit.Test
import org.junit.rules.RuleChain
import util.BasePiperTest
import util.JenkinsReadYamlRule
import util.JenkinsStepRule
import static org.junit.Assert.assertEquals
import static org.junit.Assert.assertTrue
@ -21,6 +21,7 @@ class TestsPublishResultsTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(jsr)
@Before

View File

@ -9,6 +9,7 @@ import org.junit.rules.RuleChain
import util.BasePiperTest
import util.JenkinsLoggingRule
import util.JenkinsReadYamlRule
import util.JenkinsStepRule
import util.Rules
@ -21,6 +22,7 @@ class ToolValidateTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(thrown)
.around(jlr)
.around(jsr)

View File

@ -11,11 +11,11 @@ import util.BasePiperTest
import util.JenkinsCredentialsRule
import util.JenkinsStepRule
import util.JenkinsLoggingRule
import util.JenkinsReadYamlRule
import util.Rules
import hudson.AbortException
public class TransportRequestCreateTest extends BasePiperTest {
private ExpectedException thrown = new ExpectedException()
@ -24,6 +24,7 @@ public class TransportRequestCreateTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(thrown)
.around(jsr)
.around(jlr)

View File

@ -11,12 +11,12 @@ import util.BasePiperTest
import util.JenkinsCredentialsRule
import util.JenkinsStepRule
import util.JenkinsLoggingRule
import util.JenkinsReadYamlRule
import util.Rules
import hudson.AbortException
import hudson.scm.NullSCM
public class TransportRequestReleaseTest extends BasePiperTest {
private ExpectedException thrown = new ExpectedException()
@ -25,6 +25,7 @@ public class TransportRequestReleaseTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(thrown)
.around(jsr)
.around(jlr)

View File

@ -13,11 +13,11 @@ import util.BasePiperTest
import util.JenkinsCredentialsRule
import util.JenkinsStepRule
import util.JenkinsLoggingRule
import util.JenkinsReadYamlRule
import util.Rules
import hudson.AbortException
public class TransportRequestUploadFileTest extends BasePiperTest {
private ExpectedException thrown = new ExpectedException()
@ -27,6 +27,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules.getCommonRules(this)
.around(thrown)
.around(new JenkinsReadYamlRule(this))
.around(jsr)
.around(jlr)
.around(new JenkinsCredentialsRule(this)

View File

@ -279,4 +279,32 @@ class ConfigurationHelperTest {
Assert.assertThat(configuration, hasEntry('collectTelemetryData', false))
}
@Test
public void testGStringsAreReplacedByJavaLangStrings() {
//
// needed in order to ensure we have real GStrings.
// a GString not containing variables might be optimized to
// a java.lang.String from the very beginning.
def dummy = 'Dummy',
aGString = "a${dummy}",
bGString = "b${dummy}",
cGString = "c${dummy}"
assert aGString instanceof GString
assert bGString instanceof GString
assert cGString instanceof GString
def config = new ConfigurationHelper([a: aGString,
nextLevel: [b: bGString]])
.mixin([c : cGString])
.use()
assert config == [a: 'aDummy',
c: 'cDummy',
nextLevel: [b: 'bDummy']]
assert config.a instanceof java.lang.String
assert config.c instanceof java.lang.String
assert config.nextLevel.b instanceof java.lang.String
}
}

View File

@ -19,8 +19,13 @@ import static org.junit.Assert.assertNotNull
import static org.junit.Assert.assertNull
import static org.junit.Assert.assertThat
import org.springframework.beans.factory.annotation.Autowired
class GitUtilsTest extends BasePiperTest {
@Autowired
GitUtils gitUtils
JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
ExpectedException thrown = ExpectedException.none()

View File

@ -43,4 +43,11 @@ class MapUtilsTest {
c: [ d: 'abc',
e: '']]
}
@Test
void testTraverse() {
Map m = [a: 'x1', m:[b: 'x2', c: 'otherString']]
MapUtils.traverse(m, { s -> (s.startsWith('x')) ? "replaced" : s})
assert m == [a: 'replaced', m: [b: 'replaced', c: 'otherString']]
}
}

View File

@ -12,6 +12,7 @@ import org.yaml.snakeyaml.Yaml
import groovy.json.JsonSlurper
import hudson.AbortException
import util.BasePiperTest
import util.JenkinsReadYamlRule
import util.Rules
@ -32,15 +33,13 @@ class MtaUtilsTest extends BasePiperTest {
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(thrown)
@Before
void init() {
targetMtaDescriptor = "${tmp.getRoot()}/generated_mta.yml"
def script = new Object()
mtaUtils = new MtaUtils(script)
prepareObjectInterceptors(script)
mtaUtils = new MtaUtils(nullScript)
this.helper.registerAllowedMethod('readJSON', [Map], { Map parameters ->
return new JsonSlurper().parse(new File(parameters.file))

View File

@ -40,13 +40,11 @@ class DockerArtifactVersioningTest extends BasePiperTest{
passedDir = s
return closure()
})
prepareObjectInterceptors(this)
}
@Test
void testVersioningFrom() {
av = new DockerArtifactVersioning(this, [filePath: 'Dockerfile', dockerVersionSource: 'FROM'])
av = new DockerArtifactVersioning(nullScript, [filePath: 'Dockerfile', dockerVersionSource: 'FROM'])
assertEquals('1.2.3', av.getVersion())
av.setVersion('1.2.3-20180101')
assertEquals('1.2.3-20180101', jwfr.files['VERSION'])
@ -55,15 +53,8 @@ class DockerArtifactVersioningTest extends BasePiperTest{
@Test
void testVersioningEnv() {
av = new DockerArtifactVersioning(this, [filePath: 'Dockerfile', dockerVersionSource: 'TEST'])
av = new DockerArtifactVersioning(nullScript, [filePath: 'Dockerfile', dockerVersionSource: 'TEST'])
assertEquals('2.3.4', av.getVersion())
assertTrue(jlr.log.contains('[DockerArtifactVersioning] Version from Docker environment variable TEST: 2.3.4'))
}
void prepareObjectInterceptors(object) {
object.metaClass.invokeMethod = helper.getMethodInterceptor()
object.metaClass.static.invokeMethod = helper.getMethodInterceptor()
object.metaClass.methodMissing = helper.getMethodMissingInterceptor()
}
}

View File

@ -4,8 +4,10 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
import util.BasePiperTest
import util.JenkinsReadMavenPomRule
import util.JenkinsReadYamlRule
import util.JenkinsShellCallRule
import util.Rules
@ -23,6 +25,7 @@ class MavenArtifactVersioningTest extends BasePiperTest{
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(jscr)
.around(new JenkinsReadMavenPomRule(this, 'test/resources/versioning/MavenArtifactVersioning'))

View File

@ -12,13 +12,12 @@ import static org.junit.Assert.assertEquals
class MtaArtifactVersioningTest extends BasePiperTest{
JenkinsReadYamlRule jryr = new JenkinsReadYamlRule(this, 'test/resources/versioning/MtaArtifactVersioning/')
JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(jryr)
.around(new JenkinsReadYamlRule(this).registerYaml('mta.yaml', "version: '1.2.3'"))
.around(jscr)
@Test

View File

@ -17,15 +17,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
@TestExecutionListeners(listeners = [LibraryLoadingTestExecutionListener.class], mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS)
abstract class BasePiperTest extends BasePipelineTest {
@Autowired
MockHelper mockHelper
@Autowired
Script nullScript
@Autowired
GitUtils gitUtils
@Autowired
Utils utils

View File

@ -30,16 +30,10 @@ class BasePiperTestContext {
Utils mockUtils() {
def mockUtils = new Utils()
mockUtils.steps = [
stash : { m -> println "stash name = ${m.name}" },
unstash: { println "unstash called ..." }
stash : { },
unstash: { }
]
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(mockUtils)
return mockUtils
}
@Bean
MockHelper mockHelper() {
return new MockHelper()
}
}

View File

@ -1,21 +1,27 @@
package util
import com.lesfurets.jenkins.unit.BasePipelineTest
import com.sap.piper.DefaultValueCache
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
import org.yaml.snakeyaml.Yaml
import com.lesfurets.jenkins.unit.BasePipelineTest
class JenkinsReadYamlRule implements TestRule {
final BasePipelineTest testInstance
final String testRoot
JenkinsReadYamlRule(BasePipelineTest testInstance, testRoot = '') {
// Empty project configuration file registered by default
// since almost every test needs it.
def ymls = ['.pipeline/config.yml': {''}]
JenkinsReadYamlRule(BasePipelineTest testInstance) {
this.testInstance = testInstance
this.testRoot = testRoot
}
JenkinsReadYamlRule registerYaml(fileName, yaml) {
ymls.put(fileName, yaml)
return this
}
@Override
Statement apply(Statement base, Description description) {
return statement(base)
@ -26,13 +32,17 @@ class JenkinsReadYamlRule implements TestRule {
@Override
void evaluate() throws Throwable {
testInstance.helper.registerAllowedMethod("readYaml", [Map], { Map m ->
def yml
if(m.text) {
return new Yaml().load(m.text)
yml = m.text
} else if(m.file) {
return new Yaml().load(("${this.testRoot}${m.file}" as File).text)
yml = ymls.get(m.file)
if(yml == null) throw new NullPointerException("yaml file '${m.file}' not registered.")
if(yml instanceof Closure) yml = yml()
} else {
throw new IllegalArgumentException("Key 'text' is missing in map ${m}.")
throw new IllegalArgumentException("Key 'text' and 'file' are both missing in map ${m}.")
}
return new Yaml().load(yml)
})
base.evaluate()

View File

@ -61,14 +61,18 @@ class JenkinsShellCallRule implements TestRule {
shell.add(m.script.replaceAll(/\s+/," ").trim())
if (m.returnStdout || m.returnStatus) {
def unifiedScript = unify(m.script)
def result = null
for(def e : returnValues.entrySet()) {
if(e.key.type == Type.REGEX && unifiedScript =~ e.key.script) {
return e.value
result = e.value
break
} else if(e.key.type == Type.PLAIN && unifiedScript.equals(e.key.script)) {
return e.value
result = e.value
break
}
}
return null
if(result instanceof Closure) result = result()
return result
}
})

View File

@ -1,145 +0,0 @@
#!groovy
package util
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
import hudson.tasks.junit.TestResult
import org.yaml.snakeyaml.Yaml
/**
* This is a Helper class for mocking.
*
* It can be used to load test data or to mock Jenkins or Maven specific objects.
**/
class MockHelper {
/**
* load properties from resources for mocking return value of readProperties method
* @param path to properties
* @return properties file
*/
Properties loadProperties( String path ){
Properties p = new Properties()
File pFile = new File( path )
p.load( pFile.newDataInputStream() )
return p
}
/**
* load JSON from resources for mocking return value of readJSON method
* @param path to json file
* @return json file
*/
Object loadJSON( String path ){
def js = new JsonSlurper()
def reader = new BufferedReader(new FileReader( path ))
def j = js.parse(reader)
return j
}
/**
* load YAML from resources for mocking return value of readYaml method
* @param path to yaml file
* @return yaml file
*/
Object loadYAML( String path ){
return new Yaml().load(new FileReader(path))
}
/**
* creates HTTP response for mocking return value of httpRequest method
* @param text - text to parse into json object
* @return json Object
*/
Object createResponse( String text ){
def response = new JsonBuilder(new JsonSlurper().parseText( text ))
return response
}
/**
* load File from resources for mocking return value of readFile method
* @param path to file
* @return File
*/
File loadFile( String path ){
return new File( path )
}
/**
* load POM from resources for mocking return value of readMavenPom method
* @param path to pom file
* @return Pom class
*/
MockPom loadPom(String path ){
return new MockPom( path )
}
/**
* Inner class to mock maven descriptor
*/
class MockPom {
def f
def pom
MockPom(String path){
this.f = new File( path )
if ( f.exists() ){
this.pom = new XmlSlurper().parse(f)
}
else {
throw new FileNotFoundException( 'Failed to find file: ' + path )
}
}
String getVersion(){
return pom.version
}
String getGroupId(){
return pom.groupId
}
String getArtifactId(){
return pom.artifactId
}
String getPackaging(){
return pom.packaging
}
String getName(){
return pom.name
}
}
MockBuild loadMockBuild(){
return new MockBuild()
}
MockBuild loadMockBuild(TestResult result){
return new MockBuild(result)
}
/**
* Inner class to mock Jenkins' currentBuild return object in scripts
*/
class MockBuild {
TestResult testResult
MockBuild(){}
MockBuild(TestResult result){
testResult = result
}
MockLibrary getAction(Class c){
println("MockLibrary -> getAction - arg: " + c.toString() )
return new MockLibrary()
}
class MockLibrary {
MockLibrary(){}
// return default
List getLibraries(){
println("MockLibrary -> getLibraries")
return [ [name: 'default-library', version: 'default-master', trusted: true] ]
}
TestResult getResult() {
println("MockLibrary -> getResult")
return testResult
}
}
}
}

View File

@ -13,7 +13,6 @@ public class Rules {
public static RuleChain getCommonRules(BasePipelineTest testCase, LibraryConfiguration libConfig) {
return RuleChain.outerRule(new JenkinsSetupRule(testCase, libConfig))
.around(new JenkinsReadYamlRule(testCase))
.around(new JenkinsResetDefaultCacheRule())
.around(new JenkinsErrorRule(testCase))
.around(new JenkinsEnvironmentRule(testCase))

View File

@ -1,11 +0,0 @@
_schema-version: "2.0"
ID: com.sap.samples.anything
version: 1.2.3
modules:
- name: any-ui
type: html5
path: any-ui/
resources:
- name: any-resource

View File

@ -86,21 +86,23 @@ def call(Map parameters = [:], Closure body = null) {
sh 'git add .'
sshagent([config.gitSshKeyCredentialsId]) {
def gitUserMailConfig = ''
if (config.gitUserName && config.gitUserEMail)
gitUserMailConfig = "-c user.email=\"${config.gitUserEMail}\" -c user.name=\"${config.gitUserName}\""
def gitConfig = []
try {
sh "git ${gitUserMailConfig} commit -m 'update version ${newVersion}'"
} catch (e) {
error "[${STEP_NAME}]git commit failed: ${e}"
}
if(config.gitUserEMail) gitConfig.add("-c user.email=\"${config.gitUserEMail}\"")
if(config.gitUserName) gitConfig.add("-c user.name=\"${config.gitUserName}\"")
gitConfig = gitConfig.join(' ')
try {
sh """#!/bin/bash
git tag ${config.tagPrefix}${newVersion}
git push ${config.gitSshUrl} ${config.tagPrefix}${newVersion}"""
git ${gitConfig} commit -m 'update version ${newVersion}'
git tag ${config.tagPrefix}${newVersion}"""
config.gitCommitId = gitUtils.getGitCommitIdOrNull()
} catch (e) {
error "[${STEP_NAME}]git commit and tag failed: ${e}"
}
sshagent([config.gitSshKeyCredentialsId]) {
sh "git push ${config.gitSshUrl} ${config.tagPrefix}${newVersion}"
}
}

View File

@ -12,13 +12,16 @@ import groovy.transform.Field
@Field Set STEP_CONFIG_KEYS = [
'applicationName',
'buildTarget',
'dockerImage',
'extension',
'mtaJarLocation'
]
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS.plus([
'dockerOptions'
])
def call(Map parameters = [:]) {
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
handlePipelineStepErrors(stepName: STEP_NAME, stepParameters: parameters) {
final script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
// load default & individual configuration
@ -26,58 +29,57 @@ def call(Map parameters = [:]) {
.loadStepDefaults(this)
.mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
.mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS)
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, STEP_CONFIG_KEYS)
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName ?: env.STAGE_NAME, STEP_CONFIG_KEYS)
.mixin(parameters, PARAMETER_KEYS)
.use()
new Utils().pushToSWA([step: STEP_NAME], configuration)
def java = new ToolDescriptor('Java', 'JAVA_HOME', '', '/bin/', 'java', '1.8.0', '-version 2>&1')
java.verify(this, configuration)
dockerExecute(script: script, dockerImage: configuration.dockerImage, dockerOptions: configuration.dockerOptions) {
def java = new ToolDescriptor('Java', 'JAVA_HOME', '', '/bin/', 'java', '1.8.0', '-version 2>&1')
java.verify(this, configuration)
def mta = new JavaArchiveDescriptor('SAP Multitarget Application Archive Builder', 'MTA_JAR_LOCATION', 'mtaJarLocation', '1.0.6', '-v', java)
mta.verify(this, configuration)
def mta = new JavaArchiveDescriptor('SAP Multitarget Application Archive Builder', 'MTA_JAR_LOCATION', 'mtaJarLocation', '1.0.6', '-v', java)
mta.verify(this, configuration)
def mtaYmlName = "${pwd()}/mta.yaml"
def applicationName = configuration.applicationName
def mtaYamlName = "mta.yaml"
def applicationName = configuration.applicationName
if (!fileExists(mtaYmlName)) {
if (!applicationName) {
echo "'applicationName' not provided as parameter - will not try to generate mta.yml file"
} else {
MtaUtils mtaUtils = new MtaUtils(this)
mtaUtils.generateMtaDescriptorFromPackageJson("${pwd()}/package.json", mtaYmlName, applicationName)
if (!fileExists(mtaYamlName)) {
if (!applicationName) {
echo "'applicationName' not provided as parameter - will not try to generate ${mtaYamlName} file"
} else {
MtaUtils mtaUtils = new MtaUtils(this)
mtaUtils.generateMtaDescriptorFromPackageJson("package.json", mtaYamlName, applicationName)
}
}
}
def mtaYaml = readYaml file: "${pwd()}/mta.yaml"
def mtaYaml = readYaml file: mtaYamlName
//[Q]: Why not yaml.dump()? [A]: This reformats the whole file.
sh "sed -ie \"s/\\\${timestamp}/`date +%Y%m%d%H%M%S`/g\" \"${pwd()}/mta.yaml\""
//[Q]: Why not yaml.dump()? [A]: This reformats the whole file.
sh "sed -ie \"s/\\\${timestamp}/`date +%Y%m%d%H%M%S`/g\" \"${mtaYamlName}\""
def id = mtaYaml.ID
if (!id) {
error "Property 'ID' not found in mta.yaml file at: '${pwd()}'"
}
def id = mtaYaml.ID
if (!id) {
error "Property 'ID' not found in ${mtaYamlName} file."
}
def mtarFileName = "${id}.mtar"
def mtaJar = mta.getCall(this, configuration)
def buildTarget = configuration.buildTarget
def mtarFileName = "${id}.mtar"
def mtaJar = mta.getCall(this, configuration)
def buildTarget = configuration.buildTarget
def mtaCall = "${mtaJar} --mtar ${mtarFileName} --build-target=${buildTarget}"
def mtaCall = "${mtaJar} --mtar ${mtarFileName} --build-target=${buildTarget}"
if (configuration.extension) mtaCall += " --extension=$configuration.extension"
mtaCall += ' build'
if (configuration.extension) mtaCall += " --extension=$configuration.extension"
mtaCall += ' build'
sh """#!/bin/bash
sh """#!/bin/bash
export PATH=./node_modules/.bin:${PATH}
$mtaCall
"""
def mtarFilePath = "${pwd()}/${mtarFileName}"
script?.commonPipelineEnvironment?.setMtarFilePath(mtarFilePath)
return mtarFilePath
def mtarFilePath = "${mtarFileName}"
script?.commonPipelineEnvironment?.setMtarFilePath(mtarFilePath)
}
}
}