Skip to content

Commit

Permalink
fix(config): move Central Build stage config to Build stage for custo…
Browse files Browse the repository at this point in the history
…m defaults (#5182)

* rename stage on ApplyAliasConfig func rename stage after applying alias

---------

Co-authored-by: maxcask <maxcask@gmail.com>
Co-authored-by: Googlom <alimovgb@gmail.com>
  • Loading branch information
3 people authored Nov 27, 2024
1 parent e462d32 commit 91823b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ 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)
}
if centralBuild, ok := c.Stages["Central Build"]; ok {
c.Stages["Build"] = centralBuild
delete(c.Stages, "Central Build")
}
}
for _, s := range secrets {
c.General = setParamValueFromAlias(stepName, c.General, filters.General, s.Name, s.Aliases)
Expand All @@ -81,6 +85,10 @@ 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)
}
if centralBuild, ok := c.Stages["Central Build"]; ok {
c.Stages["Build"] = centralBuild
delete(c.Stages, "Central Build")
}
}
}

Expand Down Expand Up @@ -185,6 +193,9 @@ 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: 3 additions & 0 deletions vars/commonPipelineEnvironment.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ 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 91823b9

Please sign in to comment.