Skip to content

Commit

Permalink
fix passing default params to Central Build stage steps (#5199)
Browse files Browse the repository at this point in the history
* duplicate config for Build name leave go changes only
  • Loading branch information
maxcask authored Dec 9, 2024
1 parent e8d7450 commit 97049db
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 25 deletions.
7 changes: 2 additions & 5 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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")
}
}
}
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions src/com/sap/piper/ConfigurationHelper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 2 additions & 14 deletions src/com/sap/piper/StageNameProvider.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,22 @@ 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

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)
if (technicalStageName) {
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) {
Expand Down
3 changes: 0 additions & 3 deletions vars/commonPipelineEnvironment.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 97049db

Please sign in to comment.