diff --git a/test/groovy/SetupCommonPipelineEnvironmentTest.groovy b/test/groovy/SetupCommonPipelineEnvironmentTest.groovy index d44ac3225..39531f519 100644 --- a/test/groovy/SetupCommonPipelineEnvironmentTest.groovy +++ b/test/groovy/SetupCommonPipelineEnvironmentTest.groovy @@ -4,6 +4,8 @@ import org.junit.Test import org.junit.rules.RuleChain import org.yaml.snakeyaml.Yaml +import com.sap.piper.Utils + import util.BasePiperTest import util.Rules import util.JenkinsReadYamlRule @@ -15,6 +17,7 @@ import static org.junit.Assert.assertNotNull class SetupCommonPipelineEnvironmentTest extends BasePiperTest { def usedConfigFile + def swaOldConfigUsed private JenkinsStepRule jsr = new JenkinsStepRule(this) @@ -41,6 +44,8 @@ class SetupCommonPipelineEnvironmentTest extends BasePiperTest { props.setProperty('key', 'value') return props }) + + swaOldConfigUsed = null } @Test @@ -50,8 +55,9 @@ class SetupCommonPipelineEnvironmentTest extends BasePiperTest { return path.endsWith('.pipeline/config.yml') }) - jsr.step.call(script: nullScript) + jsr.step.call(script: nullScript, utils: getSWAMockedUtils()) + assertEquals(Boolean.FALSE.toString(), swaOldConfigUsed) assertEquals('.pipeline/config.yml', usedConfigFile) assertNotNull(nullScript.commonPipelineEnvironment.configuration) assertEquals('develop', nullScript.commonPipelineEnvironment.configuration.general.productiveBranch) @@ -65,11 +71,19 @@ class SetupCommonPipelineEnvironmentTest extends BasePiperTest { return path.endsWith('.pipeline/config.properties') }) - jsr.step.call(script: nullScript) + jsr.step.call(script: nullScript, utils: getSWAMockedUtils()) + assertEquals(Boolean.TRUE.toString(), swaOldConfigUsed) assertEquals('.pipeline/config.properties', usedConfigFile) assertNotNull(nullScript.commonPipelineEnvironment.configProperties) assertEquals('value', nullScript.commonPipelineEnvironment.configProperties['key']) } + private getSWAMockedUtils() { + new Utils() { + void pushToSWA(Map payload, Map config) { + SetupCommonPipelineEnvironmentTest.this.swaOldConfigUsed = payload.stepParam5 + } + } + } } diff --git a/vars/setupCommonPipelineEnvironment.groovy b/vars/setupCommonPipelineEnvironment.groovy index 79e55be3f..e9a41c6b9 100644 --- a/vars/setupCommonPipelineEnvironment.groovy +++ b/vars/setupCommonPipelineEnvironment.groovy @@ -22,7 +22,9 @@ def call(Map parameters = [:]) { .mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS) .use() - new Utils().pushToSWA([step: STEP_NAME, stepParam4: parameters.customDefaults?'true':'false'], config) + (parameters.utils ?: new Utils()) + .pushToSWA([step: STEP_NAME, stepParam4: parameters.customDefaults?'true':'false', + stepParam5: Boolean.toString( ! (script?.commonPipelineEnvironment?.getConfigProperties() ?: [:]).isEmpty())], config) } }