Skip to content

Commit 4eb1756

Browse files
maxcaskmaxcaskGooglom
authored
fix(Central Build): Fix handling legacy stage name for Jenkins pipelines (#5151)
* add handle stageName * some improvements --------- Co-authored-by: maxcask <[email protected]> Co-authored-by: Googlom <[email protected]> Co-authored-by: Googlom <[email protected]>
1 parent 769067e commit 4eb1756

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pkg/config/evaluation.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/pkg/errors"
1010

11+
"github.com/SAP/jenkins-library/pkg/log"
1112
"github.com/SAP/jenkins-library/pkg/orchestrator"
1213
"github.com/SAP/jenkins-library/pkg/piperutils"
1314
)
@@ -39,6 +40,9 @@ func (r *RunConfigV1) evaluateConditionsV1(config *Config, utils piperutils.File
3940
// to also consider using the technical name.
4041
stageName := stage.DisplayName
4142

43+
// Central Build in Jenkins was renamed to Build.
44+
handleLegacyStageNaming(config, currentOrchestrator, stageName)
45+
4246
// Check #1: Apply explicit activation/deactivation from config file (if any)
4347
// and then evaluate stepActive conditions
4448
runStep := make(map[string]bool, len(stage.Steps))
@@ -305,3 +309,23 @@ func anyOtherStepIsActive(targetStep string, runSteps map[string]bool) bool {
305309

306310
return false
307311
}
312+
313+
func handleLegacyStageNaming(c *Config, orchestrator, stageName string) {
314+
if orchestrator == "Jenkins" && stageName == "Build" {
315+
_, buildExists := c.Stages["Build"]
316+
centralBuildStageConfig, centralBuildExists := c.Stages["Central Build"]
317+
if buildExists && centralBuildExists {
318+
log.Entry().Warnf("You have 2 entries for build stage in config.yml. " +
319+
"Parameters defined under 'Central Build' are ignored. " +
320+
"Please use only 'Build'")
321+
return
322+
}
323+
324+
if centralBuildExists {
325+
c.Stages["Build"] = centralBuildStageConfig
326+
log.Entry().Warnf("You are using 'Central Build' stage in config.yml. " +
327+
"Please move parameters under the 'Build' stage, " +
328+
"since 'Central Build' will be removed in future releases")
329+
}
330+
}
331+
}

0 commit comments

Comments
 (0)