From 0d87348c21f9565f8b706e662db9425f28897cfe Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 26 Jan 2018 13:35:49 +0100 Subject: [PATCH 1/6] Replace JenkinsConfigRule by more speaking readYaml rule and reset default cache rule. --- test/groovy/DockerExecuteTest.groovy | 4 +-- test/groovy/MTABuildTest.groovy | 5 +-- test/groovy/MavenExecuteTest.groovy | 6 ++-- test/groovy/NeoDeploymentTest.groovy | 6 ++-- test/groovy/PipelineExecuteTest.groovy | 8 ++--- test/groovy/ToolValidateTest.groovy | 6 ++-- ...Rule.groovy => JenkinsReadYamlRule.groovy} | 16 +++++---- .../util/JenkinsResetDefaultCacheRule.groovy | 34 +++++++++++++++++++ 8 files changed, 63 insertions(+), 22 deletions(-) rename test/groovy/util/{JenkinsConfigRule.groovy => JenkinsReadYamlRule.groovy} (61%) create mode 100644 test/groovy/util/JenkinsResetDefaultCacheRule.groovy diff --git a/test/groovy/DockerExecuteTest.groovy b/test/groovy/DockerExecuteTest.groovy index 9c6c425c6..78b6974be 100644 --- a/test/groovy/DockerExecuteTest.groovy +++ b/test/groovy/DockerExecuteTest.groovy @@ -6,8 +6,8 @@ import org.junit.rules.RuleChain import com.lesfurets.jenkins.unit.BasePipelineTest -import util.JenkinsConfigRule import util.JenkinsLoggingRule +import util.JenkinsReadYamlRule import util.JenkinsSetupRule import static org.junit.Assert.assertEquals @@ -22,7 +22,7 @@ class DockerExecuteTest extends BasePipelineTest { @Rule public RuleChain ruleChain = RuleChain.outerRule(new JenkinsSetupRule(this)) .around(jlr) - .around(new JenkinsConfigRule(this)) + .around(new JenkinsReadYamlRule(this)) int whichDockerReturnValue = 0 diff --git a/test/groovy/MTABuildTest.groovy b/test/groovy/MTABuildTest.groovy index 999b3b220..d026b4b37 100644 --- a/test/groovy/MTABuildTest.groovy +++ b/test/groovy/MTABuildTest.groovy @@ -10,8 +10,8 @@ import org.junit.rules.TemporaryFolder import com.lesfurets.jenkins.unit.BasePipelineTest -import util.JenkinsConfigRule import util.JenkinsLoggingRule +import util.JenkinsReadYamlRule import util.JenkinsSetupRule import util.JenkinsShellCallRule @@ -29,7 +29,8 @@ public class MTABuildTest extends BasePipelineTest { .around(new JenkinsSetupRule(this)) .around(jlr) .around(jscr) - .around(new JenkinsConfigRule(this)) + .around(new JenkinsReadYamlRule(this)) + def currentDir def otherDir diff --git a/test/groovy/MavenExecuteTest.groovy b/test/groovy/MavenExecuteTest.groovy index 2f62af7d7..5958699a3 100644 --- a/test/groovy/MavenExecuteTest.groovy +++ b/test/groovy/MavenExecuteTest.groovy @@ -9,7 +9,8 @@ import com.lesfurets.jenkins.unit.BasePipelineTest import static org.junit.Assert.assertEquals import static org.junit.Assert.assertTrue -import util.JenkinsConfigRule +import util.JenkinsReadYamlRule +import util.JenkinsResetDefaultCacheRule import util.JenkinsSetupRule import util.JenkinsShellCallRule @@ -22,7 +23,8 @@ class MavenExecuteTest extends BasePipelineTest { @Rule public RuleChain ruleChain = RuleChain.outerRule(new JenkinsSetupRule(this)) .around(jscr) - .around(new JenkinsConfigRule(this)) + .around(new JenkinsReadYamlRule(this)) + .around(new JenkinsResetDefaultCacheRule()) def mavenExecuteScript def cpe diff --git a/test/groovy/NeoDeploymentTest.groovy b/test/groovy/NeoDeploymentTest.groovy index 101f4bb84..83dbadc32 100644 --- a/test/groovy/NeoDeploymentTest.groovy +++ b/test/groovy/NeoDeploymentTest.groovy @@ -10,8 +10,9 @@ import org.junit.Test import org.junit.rules.ExpectedException import org.junit.rules.RuleChain -import util.JenkinsConfigRule + import util.JenkinsLoggingRule +import util.JenkinsReadYamlRule import util.JenkinsSetupRule import util.JenkinsShellCallRule @@ -28,7 +29,8 @@ class NeoDeploymentTest extends BasePipelineTest { .around(new JenkinsSetupRule(this)) .around(jlr) .around(jscr) - .around(new JenkinsConfigRule(this)) + .around(new JenkinsReadYamlRule(this)) + def workspacePath def warArchiveName diff --git a/test/groovy/PipelineExecuteTest.groovy b/test/groovy/PipelineExecuteTest.groovy index 782f33679..4f62d8df3 100644 --- a/test/groovy/PipelineExecuteTest.groovy +++ b/test/groovy/PipelineExecuteTest.groovy @@ -1,9 +1,5 @@ -import hudson.AbortException -import util.JenkinsConfigRule import util.JenkinsSetupRule -import org.junit.rules.TemporaryFolder - import com.lesfurets.jenkins.unit.BasePipelineTest import org.junit.Before @@ -12,6 +8,8 @@ import org.junit.Test import org.junit.rules.ExpectedException import org.junit.rules.RuleChain +import util.JenkinsReadYamlRule + class PipelineExecuteTest extends BasePipelineTest { private ExpectedException thrown = new ExpectedException().none() @@ -19,7 +17,7 @@ class PipelineExecuteTest extends BasePipelineTest { @Rule public RuleChain ruleChain = RuleChain.outerRule(thrown) .around(new JenkinsSetupRule(this)) - .around(new JenkinsConfigRule(this)) + .around(new JenkinsReadYamlRule(this)) def pipelinePath def checkoutParameters = [:] diff --git a/test/groovy/ToolValidateTest.groovy b/test/groovy/ToolValidateTest.groovy index 973f2dc59..da818a27f 100644 --- a/test/groovy/ToolValidateTest.groovy +++ b/test/groovy/ToolValidateTest.groovy @@ -9,8 +9,8 @@ import org.junit.rules.TemporaryFolder import com.lesfurets.jenkins.unit.BasePipelineTest -import util.JenkinsConfigRule import util.JenkinsLoggingRule +import util.JenkinsReadYamlRule import util.JenkinsSetupRule class ToolValidateTest extends BasePipelineTest { @@ -18,7 +18,6 @@ class ToolValidateTest extends BasePipelineTest { private ExpectedException thrown = new ExpectedException().none() private TemporaryFolder tmp = new TemporaryFolder() private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this) - private JenkinsConfigRule jcr = new JenkinsConfigRule(this) @Rule public RuleChain ruleChain = @@ -26,7 +25,8 @@ class ToolValidateTest extends BasePipelineTest { .around(thrown) .around(new JenkinsSetupRule(this)) .around(jlr) - .around(jcr) + .around(new JenkinsReadYamlRule(this)) + private notEmptyDir diff --git a/test/groovy/util/JenkinsConfigRule.groovy b/test/groovy/util/JenkinsReadYamlRule.groovy similarity index 61% rename from test/groovy/util/JenkinsConfigRule.groovy rename to test/groovy/util/JenkinsReadYamlRule.groovy index 2779501e5..187bb8d32 100644 --- a/test/groovy/util/JenkinsConfigRule.groovy +++ b/test/groovy/util/JenkinsReadYamlRule.groovy @@ -7,12 +7,12 @@ import org.junit.runner.Description import org.junit.runners.model.Statement import org.yaml.snakeyaml.Yaml -class JenkinsConfigRule implements TestRule { +class JenkinsReadYamlRule implements TestRule { final BasePipelineTest testInstance - JenkinsConfigRule(BasePipelineTest testInstance) { + JenkinsReadYamlRule(BasePipelineTest testInstance) { this.testInstance = testInstance } @@ -25,11 +25,15 @@ class JenkinsConfigRule implements TestRule { return new Statement() { @Override void evaluate() throws Throwable { - testInstance.helper.registerAllowedMethod("readYaml", [Map], { Map parameters -> - Yaml yamlParser = new Yaml() - return yamlParser.load(parameters.text) + testInstance.helper.registerAllowedMethod("readYaml", [Map], { Map m -> + if(m.text) { + return new Yaml().load(m.text) + } else if(m.file) { + throw new UnsupportedOperationException() + } else { + throw new IllegalArgumentException("Key 'text' is missing in map ${m}.") + } }) - DefaultValueCache.reset() base.evaluate() } diff --git a/test/groovy/util/JenkinsResetDefaultCacheRule.groovy b/test/groovy/util/JenkinsResetDefaultCacheRule.groovy new file mode 100644 index 000000000..680e2fc93 --- /dev/null +++ b/test/groovy/util/JenkinsResetDefaultCacheRule.groovy @@ -0,0 +1,34 @@ +package util + +import org.junit.rules.TestRule +import org.junit.runner.Description +import org.junit.runners.model.Statement + +import com.lesfurets.jenkins.unit.BasePipelineTest +import com.sap.piper.DefaultValueCache + +class JenkinsResetDefaultCacheRule implements TestRule { + + + JenkinsResetDefaultCacheRule() { + this(null) + } + + // + // Actually not needed. Only provided for the sake of consistency + // with our other rules which comes with an constructor having the + // test case contained in the signature. + JenkinsResetDefaultCacheRule(BasePipelineTest testInstance) { + } + + @Override + Statement apply(Statement base, Description description) { + return new Statement() { + @Override + void evaluate() throws Throwable { + DefaultValueCache.reset() + base.evaluate() + } + } + } +} From ef0b1bd9ddd80d075b3ddbcaf0b15b27d271f7a7 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 26 Jan 2018 14:55:15 +0100 Subject: [PATCH 2/6] [refactoring] Rule handling Starting point for that refactoring: it turned out that the tests was not independent. The DefaultValueCache which is a singleton keeps the status over various tests. Success of test execution depends on the order test execution. We have now * a dedicated rule for resetting the default value cache * JenkinsConfiguration rule (which already provided facilities for dealing with the configuration) has been replaced by a readYaml rule. From the PipelineUnit test framework we get already a handler for libraryResource, which is also part of the setup of the default values. * An auxiliar class which combines the * JenkinsSetupRule (registers the lib) * JenkinsReadYamlRule (provides facilities for Yaml parsing) * JenkinsResetDefaultValueCacheRule (cleans up the DefaultValueCache) into a rule chain. By using this rule chain we ensure that our setup OK (piper lib registered, and default config can be setup in a clean way). --- test/groovy/DockerExecuteTest.groovy | 8 +++----- test/groovy/DurationMeasureTest.groovy | 7 +++++-- test/groovy/InfluxWriteDataTest.groovy | 8 +++----- test/groovy/MTABuildTest.groovy | 9 +++------ test/groovy/MavenExecuteTest.groovy | 10 +++------- test/groovy/NeoDeploymentTest.groovy | 15 ++++++--------- test/groovy/PipelineExecuteTest.groovy | 7 +++---- .../SetupCommonPipelineEnvironmentTest.groovy | 5 +++-- test/groovy/ToolValidateTest.groovy | 13 +++++-------- test/groovy/com/sap/piper/UtilsTest.groovy | 5 ++--- test/groovy/util/JenkinsSetupRule.groovy | 5 +++-- test/groovy/util/Rules.groovy | 19 +++++++++++++++++++ 12 files changed, 58 insertions(+), 53 deletions(-) create mode 100644 test/groovy/util/Rules.groovy diff --git a/test/groovy/DockerExecuteTest.groovy b/test/groovy/DockerExecuteTest.groovy index 78b6974be..6ab08a64c 100644 --- a/test/groovy/DockerExecuteTest.groovy +++ b/test/groovy/DockerExecuteTest.groovy @@ -7,8 +7,7 @@ import org.junit.rules.RuleChain import com.lesfurets.jenkins.unit.BasePipelineTest import util.JenkinsLoggingRule -import util.JenkinsReadYamlRule -import util.JenkinsSetupRule +import util.Rules import static org.junit.Assert.assertEquals import static org.junit.Assert.assertTrue @@ -20,9 +19,8 @@ class DockerExecuteTest extends BasePipelineTest { private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this) @Rule - public RuleChain ruleChain = RuleChain.outerRule(new JenkinsSetupRule(this)) - .around(jlr) - .around(new JenkinsReadYamlRule(this)) + public RuleChain ruleChain = RuleChain.outerRule(Rules.getCommonRules(this)) + .around(jlr) int whichDockerReturnValue = 0 diff --git a/test/groovy/DurationMeasureTest.groovy b/test/groovy/DurationMeasureTest.groovy index 2b01720c2..9ba66dec8 100644 --- a/test/groovy/DurationMeasureTest.groovy +++ b/test/groovy/DurationMeasureTest.groovy @@ -1,14 +1,17 @@ #!groovy import com.lesfurets.jenkins.unit.BasePipelineTest + import org.junit.Rule import org.junit.Test -import util.JenkinsSetupRule import static org.junit.Assert.assertTrue +import org.junit.rules.RuleChain + +import util.Rules class DurationMeasureTest extends BasePipelineTest { @Rule - public JenkinsSetupRule setupRule = new JenkinsSetupRule(this) + public RuleChain rules = Rules.getCommonRules(this) @Test void testDurationMeasurement() throws Exception { diff --git a/test/groovy/InfluxWriteDataTest.groovy b/test/groovy/InfluxWriteDataTest.groovy index fd430ba04..02e39529d 100644 --- a/test/groovy/InfluxWriteDataTest.groovy +++ b/test/groovy/InfluxWriteDataTest.groovy @@ -6,7 +6,7 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.RuleChain import util.JenkinsLoggingRule -import util.JenkinsSetupRule +import util.Rules import static org.junit.Assert.assertTrue import static org.junit.Assert.assertEquals @@ -21,13 +21,11 @@ class InfluxWriteDataTest extends BasePipelineTest { def cpe - public JenkinsSetupRule setupRule = new JenkinsSetupRule(this) public JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this) @Rule - public RuleChain ruleChain = - RuleChain.outerRule(setupRule) - .around(loggingRule) + public RuleChain ruleChain = Rules.getCommonRules(this) + .around(loggingRule) @Before void init() throws Exception { diff --git a/test/groovy/MTABuildTest.groovy b/test/groovy/MTABuildTest.groovy index d026b4b37..acffca8c8 100644 --- a/test/groovy/MTABuildTest.groovy +++ b/test/groovy/MTABuildTest.groovy @@ -11,9 +11,8 @@ import org.junit.rules.TemporaryFolder import com.lesfurets.jenkins.unit.BasePipelineTest import util.JenkinsLoggingRule -import util.JenkinsReadYamlRule -import util.JenkinsSetupRule import util.JenkinsShellCallRule +import util.Rules public class MTABuildTest extends BasePipelineTest { @@ -23,13 +22,11 @@ public class MTABuildTest extends BasePipelineTest { private JenkinsShellCallRule jscr = new JenkinsShellCallRule(this) @Rule - public RuleChain ruleChain = - RuleChain.outerRule(thrown) + public RuleChain ruleChain = Rules.getCommonRules(this) + .around(thrown) .around(tmp) - .around(new JenkinsSetupRule(this)) .around(jlr) .around(jscr) - .around(new JenkinsReadYamlRule(this)) def currentDir diff --git a/test/groovy/MavenExecuteTest.groovy b/test/groovy/MavenExecuteTest.groovy index 5958699a3..4eabaaa6a 100644 --- a/test/groovy/MavenExecuteTest.groovy +++ b/test/groovy/MavenExecuteTest.groovy @@ -9,10 +9,8 @@ import com.lesfurets.jenkins.unit.BasePipelineTest import static org.junit.Assert.assertEquals import static org.junit.Assert.assertTrue -import util.JenkinsReadYamlRule -import util.JenkinsResetDefaultCacheRule -import util.JenkinsSetupRule import util.JenkinsShellCallRule +import util.Rules class MavenExecuteTest extends BasePipelineTest { @@ -21,10 +19,8 @@ class MavenExecuteTest extends BasePipelineTest { private JenkinsShellCallRule jscr = new JenkinsShellCallRule(this) @Rule - public RuleChain ruleChain = RuleChain.outerRule(new JenkinsSetupRule(this)) - .around(jscr) - .around(new JenkinsReadYamlRule(this)) - .around(new JenkinsResetDefaultCacheRule()) + public RuleChain ruleChain = Rules.getCommonRules(this) + .around(jscr) def mavenExecuteScript def cpe diff --git a/test/groovy/NeoDeploymentTest.groovy b/test/groovy/NeoDeploymentTest.groovy index 83dbadc32..2f7d4826a 100644 --- a/test/groovy/NeoDeploymentTest.groovy +++ b/test/groovy/NeoDeploymentTest.groovy @@ -12,9 +12,8 @@ import org.junit.rules.RuleChain import util.JenkinsLoggingRule -import util.JenkinsReadYamlRule -import util.JenkinsSetupRule import util.JenkinsShellCallRule +import util.Rules class NeoDeploymentTest extends BasePipelineTest { @@ -24,13 +23,11 @@ class NeoDeploymentTest extends BasePipelineTest { private JenkinsShellCallRule jscr = new JenkinsShellCallRule(this) @Rule - public RuleChain ruleChain = RuleChain.outerRule(thrown) - .around(tmp) - .around(new JenkinsSetupRule(this)) - .around(jlr) - .around(jscr) - .around(new JenkinsReadYamlRule(this)) - + public RuleChain ruleChain = Rules.getCommonRules(this) + .around(thrown) + .around(tmp) + .around(jlr) + .around(jscr) def workspacePath def warArchiveName diff --git a/test/groovy/PipelineExecuteTest.groovy b/test/groovy/PipelineExecuteTest.groovy index 4f62d8df3..1a08022cf 100644 --- a/test/groovy/PipelineExecuteTest.groovy +++ b/test/groovy/PipelineExecuteTest.groovy @@ -1,4 +1,4 @@ -import util.JenkinsSetupRule +import util.Rules import com.lesfurets.jenkins.unit.BasePipelineTest @@ -15,9 +15,8 @@ class PipelineExecuteTest extends BasePipelineTest { private ExpectedException thrown = new ExpectedException().none() @Rule - public RuleChain ruleChain = RuleChain.outerRule(thrown) - .around(new JenkinsSetupRule(this)) - .around(new JenkinsReadYamlRule(this)) + public RuleChain ruleChain = Rules.getCommonRules(this) + .around(thrown) def pipelinePath def checkoutParameters = [:] diff --git a/test/groovy/SetupCommonPipelineEnvironmentTest.groovy b/test/groovy/SetupCommonPipelineEnvironmentTest.groovy index 0f4b9498d..b95589b94 100644 --- a/test/groovy/SetupCommonPipelineEnvironmentTest.groovy +++ b/test/groovy/SetupCommonPipelineEnvironmentTest.groovy @@ -1,11 +1,12 @@ import org.junit.Before import org.junit.Rule import org.junit.Test +import org.junit.rules.RuleChain import org.yaml.snakeyaml.Yaml import com.lesfurets.jenkins.unit.BasePipelineTest -import util.JenkinsSetupRule +import util.Rules import static org.junit.Assert.assertEquals import static org.junit.Assert.assertNotNull @@ -19,7 +20,7 @@ class SetupCommonPipelineEnvironmentTest extends BasePipelineTest { def commonPipelineEnvironment @Rule - public JenkinsSetupRule jsr = new JenkinsSetupRule(this) + public RuleChain rules = Rules.getCommonRules(this) @Before void init() { diff --git a/test/groovy/ToolValidateTest.groovy b/test/groovy/ToolValidateTest.groovy index da818a27f..06800a9f4 100644 --- a/test/groovy/ToolValidateTest.groovy +++ b/test/groovy/ToolValidateTest.groovy @@ -10,8 +10,7 @@ import org.junit.rules.TemporaryFolder import com.lesfurets.jenkins.unit.BasePipelineTest import util.JenkinsLoggingRule -import util.JenkinsReadYamlRule -import util.JenkinsSetupRule +import util.Rules class ToolValidateTest extends BasePipelineTest { @@ -20,12 +19,10 @@ class ToolValidateTest extends BasePipelineTest { private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this) @Rule - public RuleChain ruleChain = - RuleChain.outerRule(tmp) - .around(thrown) - .around(new JenkinsSetupRule(this)) - .around(jlr) - .around(new JenkinsReadYamlRule(this)) + public RuleChain ruleChain = Rules.getCommonRules(this) + .around(tmp) + .around(thrown) + .around(jlr) private notEmptyDir diff --git a/test/groovy/com/sap/piper/UtilsTest.groovy b/test/groovy/com/sap/piper/UtilsTest.groovy index 211c20717..99f9127bb 100644 --- a/test/groovy/com/sap/piper/UtilsTest.groovy +++ b/test/groovy/com/sap/piper/UtilsTest.groovy @@ -6,8 +6,7 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.ExpectedException import org.junit.rules.RuleChain -import util.JenkinsLoggingRule -import util.JenkinsSetupRule +import util.Rules import util.SharedLibraryCreator import static org.hamcrest.Matchers.containsString @@ -21,7 +20,7 @@ class UtilsTest extends BasePipelineTest { public ExpectedException exception = ExpectedException.none() @Rule - public JenkinsSetupRule setUpRule = new JenkinsSetupRule(this, SharedLibraryCreator.lazyLoadedLibrary) + public RuleChain rules = Rules.getCommonRules(this, SharedLibraryCreator.lazyLoadedLibrary) Utils utils diff --git a/test/groovy/util/JenkinsSetupRule.groovy b/test/groovy/util/JenkinsSetupRule.groovy index 57bcd21ca..a2b3996b4 100644 --- a/test/groovy/util/JenkinsSetupRule.groovy +++ b/test/groovy/util/JenkinsSetupRule.groovy @@ -13,12 +13,13 @@ class JenkinsSetupRule implements TestRule { final BasePipelineTest testInstance JenkinsSetupRule(BasePipelineTest testInstance) { - this.testInstance = testInstance + this(testInstance, null) } JenkinsSetupRule(BasePipelineTest testInstance, LibraryConfiguration configuration) { this.testInstance = testInstance - this.library = configuration + if(configuration) + this.library = configuration } @Override diff --git a/test/groovy/util/Rules.groovy b/test/groovy/util/Rules.groovy new file mode 100644 index 000000000..d009d2576 --- /dev/null +++ b/test/groovy/util/Rules.groovy @@ -0,0 +1,19 @@ +package util; + +import org.junit.rules.RuleChain; + +import com.lesfurets.jenkins.unit.BasePipelineTest; +import com.lesfurets.jenkins.unit.global.lib.LibraryConfiguration + +public class Rules { + + public static RuleChain getCommonRules(BasePipelineTest testCase) { + return getCommonRules(testCase, null) + } + + public static RuleChain getCommonRules(BasePipelineTest testCase, LibraryConfiguration libConfig) { + return RuleChain.outerRule(new JenkinsSetupRule(testCase, libConfig)) + .around(new JenkinsReadYamlRule(testCase)) + .around(new JenkinsResetDefaultCacheRule()) + } +} From f52cbbe36a128edbed8f181c5631d3fd6ad85ee6 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Mon, 29 Jan 2018 12:50:59 +0100 Subject: [PATCH 3/6] Fix wrong backward compatibility handling for deployHost, deployAccount. --- test/groovy/NeoDeploymentTest.groovy | 27 +++++++++++++++++++++++++++ vars/neoDeploy.groovy | 14 ++++++++------ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/test/groovy/NeoDeploymentTest.groovy b/test/groovy/NeoDeploymentTest.groovy index 101f4bb84..a8c915f88 100644 --- a/test/groovy/NeoDeploymentTest.groovy +++ b/test/groovy/NeoDeploymentTest.groovy @@ -468,4 +468,31 @@ class NeoDeploymentTest extends BasePipelineTest { warAction: 'illegalWARAction', vmSize: 'lite') } + + @Test + void deployHostProvidedAsDeprecatedParameterTest() { + new File(workspacePath, archiveName) << "dummy archive" + cpe.setConfigProperty('CI_DEPLOY_ACCOUNT', 'configPropsUser123') + + neoDeployScript.call(script: [commonPipelineEnvironment: cpe], + archivePath: archiveName, + deployHost: "my.deploy.host.com" + ) + + assert jlr.log.contains("[WARNING][neoDeploy] Deprecated parameter 'deployHost' is used. This will not work anymore in future versions. Use parameter 'host' instead.") + } + + @Test + void deployAccountProvidedAsDeprecatedParameterTest() { + new File(workspacePath, archiveName) << "dummy archive" + cpe.setConfigProperty('CI_DEPLOY_ACCOUNT', 'configPropsUser123') + + neoDeployScript.call(script: [commonPipelineEnvironment: cpe], + archivePath: archiveName, + host: "my.deploy.host.com", + deployAccount: "myAccount" + ) + + assert jlr.log.contains("Deprecated parameter 'deployAccount' is used. This will not work anymore in future versions. Use parameter 'account' instead.") + } } diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index e072ee2af..c49fc102c 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -11,6 +11,8 @@ def call(parameters = [:]) { 'applicationName', 'archivePath', 'account', + 'deployAccount', //deprecated, replaced by parameter 'account' + 'deployHost', //deprecated, replaced by parameter 'host' 'deployMode', 'dockerEnvVars', 'dockerImage', @@ -60,14 +62,14 @@ def call(parameters = [:]) { stepConfiguration.put('account', defaultDeployAccount) } - if(parameters.DEPLOY_HOST && !parameters.host) { - echo "[WARNING][${stepName}] Deprecated parameter 'DEPLOY_HOST' is used. This will not work anymore in future versions. Use parameter 'host' instead." - parameters.put('host', parameters.DEPLOY_HOST) + if(parameters.deployHost && !parameters.host) { + echo "[WARNING][${stepName}] Deprecated parameter 'deployHost' is used. This will not work anymore in future versions. Use parameter 'host' instead." + parameters.put('host', parameters.deployHost) } - if(parameters.CI_DEPLOY_ACCOUNT && !parameters.account) { - echo "[WARNING][${stepName}] Deprecated parameter 'CI_DEPLOY_ACCOUNT' is used. This will not work anymore in future versions. Use parameter 'account' instead." - parameters.put('account', parameters.CI_DEPLOY_ACCOUNT) + if(parameters.deployAccount && !parameters.account) { + echo "[WARNING][${stepName}] Deprecated parameter 'deployAccount' is used. This will not work anymore in future versions. Use parameter 'account' instead." + parameters.put('account', parameters.deployAccount) } // Backward compatibility end From e3590c8603c469f743170ef2437091df52dfe0e3 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 30 Jan 2018 17:09:17 +0100 Subject: [PATCH 4/6] [fix] ensure backward compatitility for credentials id --- vars/neoDeploy.groovy | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index c49fc102c..4e53463e3 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -72,6 +72,13 @@ def call(parameters = [:]) { parameters.put('account', parameters.deployAccount) } + def credId = script.commonPipelineEnvironment.getConfigProperty('neoCredentialsId') + + if(credId && !parameters.neoCredentialsId) { + echo "[WARNING][${stepName}] Deprecated parameter 'neoCredentialsId' from old configuration framework is used. This will not work anymore in future versions." + parameters.put('neoCredentialsId', credId) + } + // Backward compatibility end stepConfiguration.putAll(ConfigurationLoader.stepConfiguration(script, stepName)) From 1361c0320292b678f947c6d6aab5d320d6b14a5b Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Wed, 31 Jan 2018 10:09:45 +0100 Subject: [PATCH 5/6] adapt editor config foy yaml files --- .editorconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.editorconfig b/.editorconfig index e26065a81..91ee29022 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,3 +11,5 @@ indent_style = space indent_size = 4 insert_final_newline = true trim_trailing_whitespace = true +[*.{yml,yaml}] +indent_size = 2 From 485eff717588dd8460138f464a24a55e92e26b29 Mon Sep 17 00:00:00 2001 From: Alejandra Ferreiro Vidal Date: Wed, 31 Jan 2018 17:17:01 +0100 Subject: [PATCH 6/6] bugfix absolute path --- test/groovy/MTABuildTest.groovy | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/groovy/MTABuildTest.groovy b/test/groovy/MTABuildTest.groovy index acffca8c8..100aa8969 100644 --- a/test/groovy/MTABuildTest.groovy +++ b/test/groovy/MTABuildTest.groovy @@ -120,12 +120,13 @@ public class MTABuildTest extends BasePipelineTest { binding.getVariable('env')['MTA_JAR_LOCATION'] = '/opt/mta' def newDirName = 'newDir' - def newDir = new File("${currentDir}/${newDirName}") + def newDirPath = "${currentDir}/${newDirName}" + def newDir = new File(newDirPath) newDir.mkdirs() new File(newDir, 'mta.yaml') << defaultMtaYaml() - helper.registerAllowedMethod('pwd', [], { newDir } ) + helper.registerAllowedMethod('pwd', [], { newDirPath } ) def mtarFilePath = mtaBuildScript.call(script: [commonPipelineEnvironment: cpe], buildTarget: 'NEO')