mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
Revert "ConfigurationLoader, ConfigurationHelper working without script reference"
This reverts commit 9962060254
.
This commit is contained in:
parent
4bbfd78437
commit
d0d4b37b24
@ -34,31 +34,18 @@ class ConfigurationHelper implements Serializable {
|
||||
return this
|
||||
}
|
||||
|
||||
ConfigurationHelper mixinGeneralConfig(Set filter = null, Map compatibleParameters = [:]){
|
||||
mixinGeneralConfig(null, filter, compatibleParameters)
|
||||
}
|
||||
@Deprecated
|
||||
/** Use mixinGeneralConfig without commonPipelineEnvironment*/
|
||||
ConfigurationHelper mixinGeneralConfig(commonPipelineEnvironment, Set filter = null, Map compatibleParameters = [:]){
|
||||
Map generalConfiguration = ConfigurationLoader.generalConfiguration()
|
||||
Map generalConfiguration = ConfigurationLoader.generalConfiguration([commonPipelineEnvironment: commonPipelineEnvironment])
|
||||
return mixin(generalConfiguration, filter, compatibleParameters)
|
||||
}
|
||||
|
||||
ConfigurationHelper mixinStageConfig(stageName, Set filter = null, Map compatibleParameters = [:]){
|
||||
mixinStageConfig(null, stageName, filter, compatibleParameters)
|
||||
}
|
||||
@Deprecated
|
||||
ConfigurationHelper mixinStageConfig(commonPipelineEnvironment, stageName, Set filter = null, Map compatibleParameters = [:]){
|
||||
Map stageConfiguration = ConfigurationLoader.stageConfiguration(stageName)
|
||||
Map stageConfiguration = ConfigurationLoader.stageConfiguration([commonPipelineEnvironment: commonPipelineEnvironment], stageName)
|
||||
return mixin(stageConfiguration, filter, compatibleParameters)
|
||||
}
|
||||
|
||||
ConfigurationHelper mixinStepConfig(Set filter = null, Map compatibleParameters = [:]){
|
||||
mixinStepConfig(null, filter, compatibleParameters)
|
||||
}
|
||||
@Deprecated
|
||||
ConfigurationHelper mixinStepConfig(commonPipelineEnvironment, Set filter = null, Map compatibleParameters = [:]){
|
||||
Map stepConfiguration = ConfigurationLoader.stepConfiguration(name)
|
||||
Map stepConfiguration = ConfigurationLoader.stepConfiguration([commonPipelineEnvironment: commonPipelineEnvironment], name)
|
||||
return mixin(stepConfiguration, filter, compatibleParameters)
|
||||
}
|
||||
|
||||
|
@ -1,83 +1,44 @@
|
||||
package com.sap.piper
|
||||
|
||||
// script is present in the signatures in order to keep api compatibility.
|
||||
// The script referenced is not used inside the method bodies.
|
||||
|
||||
@API(deprecated = true)
|
||||
class ConfigurationLoader implements Serializable {
|
||||
|
||||
static Map stepConfiguration(String stepName) {
|
||||
return loadConfiguration('steps', stepName, ConfigurationType.CUSTOM_CONFIGURATION)
|
||||
}
|
||||
@Deprecated
|
||||
/** Use stepConfiguration(stepName) instead */
|
||||
static Map stepConfiguration(script, String stepName) {
|
||||
return stepConfiguration(stepName)
|
||||
return loadConfiguration(script, 'steps', stepName, ConfigurationType.CUSTOM_CONFIGURATION)
|
||||
}
|
||||
|
||||
static Map stageConfiguration(String stageName) {
|
||||
return loadConfiguration('stages', stageName, ConfigurationType.CUSTOM_CONFIGURATION)
|
||||
}
|
||||
@Deprecated
|
||||
/** Use stageConfiguration(stageName) instead */
|
||||
static Map stageConfiguration(script, String stageName) {
|
||||
return stageConfiguration(stageName)
|
||||
return loadConfiguration(script, 'stages', stageName, ConfigurationType.CUSTOM_CONFIGURATION)
|
||||
}
|
||||
|
||||
static Map defaultStepConfiguration(String stepName) {
|
||||
return loadConfiguration('steps', stepName, ConfigurationType.DEFAULT_CONFIGURATION)
|
||||
}
|
||||
@Deprecated
|
||||
/** Use defaultStepConfiguration(stepName) instead */
|
||||
static Map defaultStepConfiguration(script, String stepName) {
|
||||
return defaultStepConfiguration(stepName)
|
||||
return loadConfiguration(script, 'steps', stepName, ConfigurationType.DEFAULT_CONFIGURATION)
|
||||
}
|
||||
|
||||
static Map defaultStageConfiguration(String stageName) {
|
||||
return loadConfiguration('stages', stageName, ConfigurationType.DEFAULT_CONFIGURATION)
|
||||
}
|
||||
@Deprecated
|
||||
/** Use defaultStageConfiguration(stepName) instead */
|
||||
static Map defaultStageConfiguration(script, String stageName) {
|
||||
return defaultStageConfiguration(stageName)
|
||||
return loadConfiguration(script, 'stages', stageName, ConfigurationType.DEFAULT_CONFIGURATION)
|
||||
}
|
||||
|
||||
static Map generalConfiguration(){
|
||||
static Map generalConfiguration(script){
|
||||
try {
|
||||
return CommonPipelineEnvironment.getInstance()?.configuration?.general ?: [:]
|
||||
return script?.commonPipelineEnvironment?.configuration?.general ?: [:]
|
||||
} catch (groovy.lang.MissingPropertyException mpe) {
|
||||
return [:]
|
||||
}
|
||||
}
|
||||
@Deprecated
|
||||
/** Use generalConfiguration() instead */
|
||||
static Map generalConfiguration(script){
|
||||
return generalConfiguration()
|
||||
}
|
||||
|
||||
static Map defaultGeneralConfiguration(){
|
||||
static Map defaultGeneralConfiguration(script){
|
||||
return DefaultValueCache.getInstance()?.getDefaultValues()?.general ?: [:]
|
||||
}
|
||||
@Deprecated
|
||||
/** Use defaultGeneralConfiguration() instead */
|
||||
static Map defaultGeneralConfiguration(script){
|
||||
return defaultGeneralConfiguration()
|
||||
}
|
||||
|
||||
static Map postActionConfiguration(String actionName){
|
||||
return loadConfiguration('postActions', actionName, ConfigurationType.CUSTOM_CONFIGURATION)
|
||||
}
|
||||
@Deprecated
|
||||
/** Use postActionConfiguration() instead */
|
||||
static Map postActionConfiguration(script, String actionName){
|
||||
return postActionConfiguration(actionName)
|
||||
return loadConfiguration(script, 'postActions', actionName, ConfigurationType.CUSTOM_CONFIGURATION)
|
||||
}
|
||||
|
||||
private static Map loadConfiguration(String type, String entryName, ConfigurationType configType){
|
||||
private static Map loadConfiguration(script, String type, String entryName, ConfigurationType configType){
|
||||
switch (configType) {
|
||||
case ConfigurationType.CUSTOM_CONFIGURATION:
|
||||
try {
|
||||
return CommonPipelineEnvironment.getInstance()?.configuration?.get(type)?.get(entryName) ?: [:]
|
||||
return script?.commonPipelineEnvironment?.configuration?.get(type)?.get(entryName) ?: [:]
|
||||
} catch (groovy.lang.MissingPropertyException mpe) {
|
||||
return [:]
|
||||
}
|
||||
|
@ -3,9 +3,6 @@ import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import com.sap.piper.CommonPipelineEnvironment
|
||||
|
||||
import org.junit.Ignore
|
||||
|
||||
import util.BasePiperTest
|
||||
@ -157,10 +154,9 @@ class ChecksPublishResultsTest extends BasePiperTest {
|
||||
@Test
|
||||
void testPublishWithChangedStepDefaultSettings() throws Exception {
|
||||
// pmd has been set to active: true in step configuration
|
||||
CommonPipelineEnvironment.getInstance().configuration =
|
||||
[steps: [checksPublishResults: [pmd: [active: true]]]]
|
||||
|
||||
stepRule.step.checksPublishResults([script: nullScript])
|
||||
stepRule.step.checksPublishResults(script: [commonPipelineEnvironment: [
|
||||
configuration: [steps: [checksPublishResults: [pmd: [active: true]]]]
|
||||
]])
|
||||
|
||||
assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null)
|
||||
assertTrue("PmdPublisher options not set", publisherStepOptions['PmdPublisher'] != null)
|
||||
|
@ -101,17 +101,11 @@ class ConfigurationHelperTest {
|
||||
@Test
|
||||
void testConfigurationHelperLoadingStepDefaults() {
|
||||
Set filter = ['property2']
|
||||
CommonPipelineEnvironment.getInstance().configuration = [
|
||||
general: ['general': 'test', 'oldGeneral': 'test2'],
|
||||
stages: [testStage:['stage': 'test', 'oldStage': 'test2']],
|
||||
steps: [mock: [step: 'test', 'oldStep': 'test2']]
|
||||
]
|
||||
|
||||
Map config = ConfigurationHelper.newInstance(mockScript, [property1: '27'])
|
||||
.loadStepDefaults()
|
||||
.mixinGeneralConfig(null, [general2: 'oldGeneral'])
|
||||
.mixinStageConfig('testStage', null, [stage2: 'oldStage'])
|
||||
.mixinStepConfig(null, [step2: 'oldStep'])
|
||||
.mixinGeneralConfig([configuration:[general: ['general': 'test', 'oldGeneral': 'test2']]], null, [general2: 'oldGeneral'])
|
||||
.mixinStageConfig([configuration:[stages:[testStage:['stage': 'test', 'oldStage': 'test2']]]], 'testStage', null, [stage2: 'oldStage'])
|
||||
.mixinStepConfig([configuration:[steps:[mock: [step: 'test', 'oldStep': 'test2']]]], null, [step2: 'oldStep'])
|
||||
.mixin([property1: '41', property2: '28', property3: '29'], filter)
|
||||
.use()
|
||||
// asserts
|
||||
|
@ -17,9 +17,9 @@ class ConfigurationLoaderTest {
|
||||
defaultConfiguration.steps = [executeGradle: [dockerImage: 'gradle:4.0.1-jdk8']]
|
||||
defaultConfiguration.stages = [staticCodeChecks: [pmdExcludes: '*.java']]
|
||||
|
||||
def pipelineEnvironment = [configuration: configuration]
|
||||
DefaultValueCache.createInstance(defaultConfiguration)
|
||||
CommonPipelineEnvironment.getInstance().configuration = configuration
|
||||
return [commonPipelineEnvironment: [configuration: configuration]]
|
||||
return [commonPipelineEnvironment: pipelineEnvironment]
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user