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

Merge pull request #322 from marcusholl/pr/swaPushOldConfigUsed

swa push old config used
This commit is contained in:
Marcus Holl 2018-10-11 08:42:52 +02:00 committed by GitHub
commit a56b9c0c8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -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
}
}
}
}

View File

@ -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)
}
}