1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-30 05:59:39 +02:00

remove config.properties file

This commit is contained in:
Alejandra Ferreiro Vidal 2019-03-26 14:13:03 +01:00
parent 0e7ef41fab
commit e282c07dd4
3 changed files with 6 additions and 68 deletions

View File

@ -16,8 +16,8 @@ import static org.junit.Assert.assertNotNull
class SetupCommonPipelineEnvironmentTest extends BasePiperTest {
def usedConfigFile
def swaOldConfigUsed
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
@ -28,6 +28,7 @@ class SetupCommonPipelineEnvironmentTest extends BasePiperTest {
@Before
void init() {
def examplePipelineConfig = new File('test/resources/test_pipeline_config.yml').text
helper.registerAllowedMethod("readYaml", [Map], { Map parameters ->
@ -38,14 +39,6 @@ class SetupCommonPipelineEnvironmentTest extends BasePiperTest {
usedConfigFile = parameters.file
return yamlParser.load(examplePipelineConfig)
})
helper.registerAllowedMethod("readProperties", [Map], { Map parameters ->
usedConfigFile = parameters.file
Properties props = new Properties()
props.setProperty('key', 'value')
return props
})
swaOldConfigUsed = null
}
@Test
@ -55,35 +48,12 @@ class SetupCommonPipelineEnvironmentTest extends BasePiperTest {
return path.endsWith('.pipeline/config.yml')
})
stepRule.step.setupCommonPipelineEnvironment(script: nullScript, utils: getSWAMockedUtils())
stepRule.step.setupCommonPipelineEnvironment(script: nullScript)
assertEquals(Boolean.FALSE.toString(), swaOldConfigUsed)
assertEquals('.pipeline/config.yml', usedConfigFile)
assertNotNull(nullScript.commonPipelineEnvironment.configuration)
assertEquals('develop', nullScript.commonPipelineEnvironment.configuration.general.productiveBranch)
assertEquals('my-maven-docker', nullScript.commonPipelineEnvironment.configuration.steps.mavenExecute.dockerImage)
}
@Test
void testIsPropertiesConfigurationAvailable() {
helper.registerAllowedMethod("fileExists", [String], { String path ->
return path.endsWith('.pipeline/config.properties')
})
stepRule.step.setupCommonPipelineEnvironment(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

@ -2,7 +2,6 @@ import com.sap.piper.ConfigurationLoader
import com.sap.piper.ConfigurationMerger
class commonPipelineEnvironment implements Serializable {
Map configProperties = [:]
//stores version of the artifact which is build during pipeline run
def artifactVersion
@ -44,7 +43,6 @@ class commonPipelineEnvironment implements Serializable {
appContainerProperties = [:]
artifactVersion = null
configProperties = [:]
configuration = [:]
gitCommitId = null
@ -74,17 +72,6 @@ class commonPipelineEnvironment implements Serializable {
return appContainerProperties[property]
}
def setConfigProperty(property, value) {
configProperties[property] = value
}
def getConfigProperty(property) {
if (configProperties[property] != null)
return configProperties[property].trim()
else
return configProperties[property]
}
// goes into measurement jenkins_data
def setInfluxCustomDataEntry(field, value) {
influxCustomData[field] = value

View File

@ -27,9 +27,7 @@ void call(Map parameters = [:]) {
(parameters.utils ?: new Utils()).pushToSWA([
step: STEP_NAME,
stepParamKey4: 'customDefaults',
stepParam4: parameters.customDefaults?'true':'false',
stepParamKey5: 'legacyConfig',
stepParam5: Boolean.toString( ! (script?.commonPipelineEnvironment?.getConfigProperties() ?: [:]).isEmpty())
stepParam4: parameters.customDefaults?'true':'false'
], config)
script.commonPipelineEnvironment.setInfluxStepData('build_url', env.BUILD_URL)
@ -37,28 +35,11 @@ void call(Map parameters = [:]) {
}
}
private boolean isYaml(String fileName) {
return fileName.endsWith(".yml") || fileName.endsWith(".yaml")
}
private boolean isProperties(String fileName) {
return fileName.endsWith(".properties")
}
private loadConfigurationFromFile(script, String configFile) {
String defaultPropertiesConfigFile = '.pipeline/config.properties'
String defaultYmlConfigFile = '.pipeline/config.yml'
if (configFile?.trim()?.length() > 0 && isProperties(configFile)) {
Map configMap = readProperties(file: configFile)
script.commonPipelineEnvironment.setConfigProperties(configMap)
} else if (fileExists(defaultPropertiesConfigFile)) {
Map configMap = readProperties(file: defaultPropertiesConfigFile)
script.commonPipelineEnvironment.setConfigProperties(configMap)
}
if (configFile?.trim()?.length() > 0 && isYaml(configFile)) {
if (configFile) {
script.commonPipelineEnvironment.configuration = readYaml(file: configFile)
} else if (fileExists(defaultYmlConfigFile)) {
script.commonPipelineEnvironment.configuration = readYaml(file: defaultYmlConfigFile)