Skip to content

Commit

Permalink
handle new naming strategy for Central Build stage name (#5171)
Browse files Browse the repository at this point in the history
* config helper rename

* rename in name provider 
---------

Co-authored-by: maxcask <[email protected]>
  • Loading branch information
maxcask and maxcask authored Nov 12, 2024
1 parent 1edf829 commit 758d10b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/com/sap/piper/ConfigurationHelper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ 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
17 changes: 15 additions & 2 deletions src/com/sap/piper/StageNameProvider.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,34 @@ 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) {
return parameters.stageName
stageName = parameters.stageName
stageName = replaceCentralBuild(stageName);
return stageName
}
if (this.useTechnicalStageNames) {
String technicalStageName = getTechnicalStageName(step)
if (technicalStageName) {
return technicalStageName
}
}
return script.env.STAGE_NAME
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;
}

static String getTechnicalStageName(Script step) {
Expand Down

0 comments on commit 758d10b

Please sign in to comment.