From 97049db02f995fc63f9aa4ed669240761300f5d4 Mon Sep 17 00:00:00 2001 From: maxcask Date: Mon, 9 Dec 2024 10:44:44 +0400 Subject: [PATCH] fix passing default params to Central Build stage steps (#5199) * duplicate config for Build name leave go changes only --- pkg/config/config.go | 7 ++----- src/com/sap/piper/ConfigurationHelper.groovy | 3 --- src/com/sap/piper/StageNameProvider.groovy | 16 ++-------------- vars/commonPipelineEnvironment.groovy | 3 --- 4 files changed, 4 insertions(+), 25 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index ddfaf50c4e..05bce93f7e 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -72,9 +72,9 @@ func (c *Config) ApplyAliasConfig(parameters []StepParameters, secrets []StepSec if c.Steps[stepName] != nil { c.Steps[stepName] = setParamValueFromAlias(stepName, c.Steps[stepName], filters.Steps, p.Name, p.Aliases) } + //copy stage configuration with Build name if centralBuild, ok := c.Stages["Central Build"]; ok { c.Stages["Build"] = centralBuild - delete(c.Stages, "Central Build") } } for _, s := range secrets { @@ -85,9 +85,9 @@ func (c *Config) ApplyAliasConfig(parameters []StepParameters, secrets []StepSec if c.Steps[stepName] != nil { c.Steps[stepName] = setParamValueFromAlias(stepName, c.Steps[stepName], filters.Steps, s.Name, s.Aliases) } + //copy stage secrets configuration with Build name if centralBuild, ok := c.Stages["Central Build"]; ok { c.Stages["Build"] = centralBuild - delete(c.Stages, "Central Build") } } } @@ -193,9 +193,6 @@ func (c *Config) GetStepConfig(flagValues map[string]interface{}, paramJSON stri } c.ApplyAliasConfig(parameters, secrets, filters, stageName, stepName, stepAliases) - if stageName == "Central Build" { - stageName = "Build" - } // initialize with defaults from step.yaml stepConfig.mixInStepDefaults(parameters) diff --git a/src/com/sap/piper/ConfigurationHelper.groovy b/src/com/sap/piper/ConfigurationHelper.groovy index b6b1558ddf..2eeaaf0e6f 100644 --- a/src/com/sap/piper/ConfigurationHelper.groovy +++ b/src/com/sap/piper/ConfigurationHelper.groovy @@ -10,9 +10,6 @@ class ConfigurationHelper implements Serializable { } ConfigurationHelper loadStepDefaults(Map compatibleParameters = [:], String stageName = step.env.STAGE_NAME) { - if (stageName == 'Central Build'){ - stageName = 'Build' - } DefaultValueCache.prepare(step) this.config = ConfigurationLoader.defaultGeneralConfiguration() mixin(ConfigurationLoader.defaultGeneralConfiguration(), null, compatibleParameters) diff --git a/src/com/sap/piper/StageNameProvider.groovy b/src/com/sap/piper/StageNameProvider.groovy index cd2fa71f06..ceb7967629 100644 --- a/src/com/sap/piper/StageNameProvider.groovy +++ b/src/com/sap/piper/StageNameProvider.groovy @@ -3,8 +3,6 @@ package com.sap.piper @Singleton class StageNameProvider implements Serializable { static final long serialVersionUID = 1L - static final String CENTRAL_BUILD = "Central Build"; - static final String BUILD = "Build"; /** Stores a feature toggle for defaulting to technical names in stages */ boolean useTechnicalStageNames = false @@ -12,9 +10,7 @@ class StageNameProvider implements Serializable { String getStageName(Script script, Map parameters, Script step) { String stageName = null if (parameters.stageName in CharSequence) { - stageName = parameters.stageName - stageName = replaceCentralBuild(stageName); - return stageName + return parameters.stageName } if (this.useTechnicalStageNames) { String technicalStageName = getTechnicalStageName(step) @@ -22,15 +18,7 @@ class StageNameProvider implements Serializable { return technicalStageName } } - if (stageName == null) { - stageName = script.env.STAGE_NAME - stageName = replaceCentralBuild(stageName); - } - return stageName - } - - private String replaceCentralBuild(String stageName) { - return CENTRAL_BUILD.equals(stageName) ? BUILD : stageName; + return script.env.STAGE_NAME } static String getTechnicalStageName(Script step) { diff --git a/vars/commonPipelineEnvironment.groovy b/vars/commonPipelineEnvironment.groovy index 90e3a871d3..b44842d9ca 100644 --- a/vars/commonPipelineEnvironment.groovy +++ b/vars/commonPipelineEnvironment.groovy @@ -192,9 +192,6 @@ class commonPipelineEnvironment implements Serializable { Map getStepConfiguration(stepName, stageName = env.STAGE_NAME, includeDefaults = true) { Map defaults = [:] - if (stageName == 'Central Build') { - stageName = 'Build' - } if (includeDefaults) { defaults = ConfigurationLoader.defaultGeneralConfiguration() defaults = ConfigurationMerger.merge(ConfigurationLoader.defaultStepConfiguration(null, stepName), null, defaults)