Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set stage name Build for Central Build #5116

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion cmd/getConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/SAP/jenkins-library/pkg/config"
"github.com/SAP/jenkins-library/pkg/log"
"github.com/SAP/jenkins-library/pkg/orchestrator"
"github.com/SAP/jenkins-library/pkg/piperutils"
"github.com/SAP/jenkins-library/pkg/reporting"
ws "github.com/SAP/jenkins-library/pkg/whitesource"
Expand Down Expand Up @@ -127,6 +128,7 @@ func GetStageConfig() (config.StepConfig, error) {
myConfig := config.Config{}
stepConfig := config.StepConfig{}
projectConfigFile := getProjectConfigFile(GeneralConfig.CustomConfig)
currentOrchestrator := orchestrator.DetectOrchestrator().String()

customConfig, err := configOptions.OpenFile(projectConfigFile, GeneralConfig.GitHubAccessTokens)
if err != nil {
Expand All @@ -148,13 +150,25 @@ func GetStageConfig() (config.StepConfig, error) {
}
}

return myConfig.GetStageConfig(GeneralConfig.ParametersJSON, customConfig, defaultConfig, GeneralConfig.IgnoreCustomDefaults, configOptions.StageConfigAcceptedParameters, GeneralConfig.StageName)
cfg, err := myConfig.GetStageConfig(GeneralConfig.ParametersJSON, customConfig, defaultConfig, GeneralConfig.IgnoreCustomDefaults, configOptions.StageConfigAcceptedParameters, GeneralConfig.StageName)

if currentOrchestrator == "Jenkins" {
log.Entry().Info("CBfix: replacing stage name")
if stage, ok := myConfig.Stages["Central Build"]; ok {
log.Entry().Info("CBfix: Central Build stage name found")
delete(myConfig.Stages, "Central Build") // Remove "Central Build" stage name
myConfig.Stages["Build"] = stage // Assign the inner steps map "Build" stage name
}
}

return cfg, err
}

func getConfig() (config.StepConfig, error) {
var myConfig config.Config
var stepConfig config.StepConfig
var err error
currentOrchestrator := orchestrator.DetectOrchestrator().String()

if configOptions.StageConfig {
stepConfig, err = GetStageConfig()
Expand Down Expand Up @@ -214,6 +228,17 @@ func getConfig() (config.StepConfig, error) {
metadata.Spec.Inputs.Parameters = []config.StepParameters{}
}

myConfig.GetStageConfig(GeneralConfig.ParametersJSON, customConfig, defaultConfig, GeneralConfig.IgnoreCustomDefaults, configOptions.StageConfigAcceptedParameters, GeneralConfig.StageName)

if currentOrchestrator == "Jenkins" {
log.Entry().Info("CBfix: replacing stage name")
if stage, ok := myConfig.Stages["Central Build"]; ok {
log.Entry().Info("CBfix: Central Build stage name found")
delete(myConfig.Stages, "Central Build") // Remove "Central Build" stage name
myConfig.Stages["Build"] = stage // Assign the inner steps map "Build" stage name
}
}

stepConfig, err = myConfig.GetStepConfig(flags, GeneralConfig.ParametersJSON, customConfig, defaultConfig, GeneralConfig.IgnoreCustomDefaults, paramFilter, metadata, resourceParams, GeneralConfig.StageName, metadata.Metadata.Name)
if err != nil {
return stepConfig, errors.Wrap(err, "getting step config failed")
Expand Down
Loading