mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-16 05:16:08 +02:00
fix(Central Build): Fix handling legacy stage name for Jenkins pipelines (#5151)
* add handle stageName * some improvements --------- Co-authored-by: maxcask <maxcask@gmail.com> Co-authored-by: Googlom <alimovgb@gmail.com> Co-authored-by: Googlom <36107508+Googlom@users.noreply.github.com>
This commit is contained in:
parent
769067e996
commit
4eb1756b54
@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/SAP/jenkins-library/pkg/log"
|
||||
"github.com/SAP/jenkins-library/pkg/orchestrator"
|
||||
"github.com/SAP/jenkins-library/pkg/piperutils"
|
||||
)
|
||||
@ -39,6 +40,9 @@ func (r *RunConfigV1) evaluateConditionsV1(config *Config, utils piperutils.File
|
||||
// to also consider using the technical name.
|
||||
stageName := stage.DisplayName
|
||||
|
||||
// Central Build in Jenkins was renamed to Build.
|
||||
handleLegacyStageNaming(config, currentOrchestrator, stageName)
|
||||
|
||||
// Check #1: Apply explicit activation/deactivation from config file (if any)
|
||||
// and then evaluate stepActive conditions
|
||||
runStep := make(map[string]bool, len(stage.Steps))
|
||||
@ -305,3 +309,23 @@ func anyOtherStepIsActive(targetStep string, runSteps map[string]bool) bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func handleLegacyStageNaming(c *Config, orchestrator, stageName string) {
|
||||
if orchestrator == "Jenkins" && stageName == "Build" {
|
||||
_, buildExists := c.Stages["Build"]
|
||||
centralBuildStageConfig, centralBuildExists := c.Stages["Central Build"]
|
||||
if buildExists && centralBuildExists {
|
||||
log.Entry().Warnf("You have 2 entries for build stage in config.yml. " +
|
||||
"Parameters defined under 'Central Build' are ignored. " +
|
||||
"Please use only 'Build'")
|
||||
return
|
||||
}
|
||||
|
||||
if centralBuildExists {
|
||||
c.Stages["Build"] = centralBuildStageConfig
|
||||
log.Entry().Warnf("You are using 'Central Build' stage in config.yml. " +
|
||||
"Please move parameters under the 'Build' stage, " +
|
||||
"since 'Central Build' will be removed in future releases")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user