Skip to content

Commit 758d10b

Browse files
maxcaskmaxcask
and
maxcask
authored
handle new naming strategy for Central Build stage name (#5171)
* config helper rename * rename in name provider --------- Co-authored-by: maxcask <[email protected]>
1 parent 1edf829 commit 758d10b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/com/sap/piper/ConfigurationHelper.groovy

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ class ConfigurationHelper implements Serializable {
1010
}
1111

1212
ConfigurationHelper loadStepDefaults(Map compatibleParameters = [:], String stageName = step.env.STAGE_NAME) {
13+
if (stageName == 'Central Build'){
14+
stageName = 'Build'
15+
}
1316
DefaultValueCache.prepare(step)
1417
this.config = ConfigurationLoader.defaultGeneralConfiguration()
1518
mixin(ConfigurationLoader.defaultGeneralConfiguration(), null, compatibleParameters)

src/com/sap/piper/StageNameProvider.groovy

+15-2
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,34 @@ package com.sap.piper
33
@Singleton
44
class StageNameProvider implements Serializable {
55
static final long serialVersionUID = 1L
6+
static final String CENTRAL_BUILD = "Central Build";
7+
static final String BUILD = "Build";
68

79
/** Stores a feature toggle for defaulting to technical names in stages */
810
boolean useTechnicalStageNames = false
911

1012
String getStageName(Script script, Map parameters, Script step) {
13+
String stageName = null
1114
if (parameters.stageName in CharSequence) {
12-
return parameters.stageName
15+
stageName = parameters.stageName
16+
stageName = replaceCentralBuild(stageName);
17+
return stageName
1318
}
1419
if (this.useTechnicalStageNames) {
1520
String technicalStageName = getTechnicalStageName(step)
1621
if (technicalStageName) {
1722
return technicalStageName
1823
}
1924
}
20-
return script.env.STAGE_NAME
25+
if (stageName == null) {
26+
stageName = script.env.STAGE_NAME
27+
stageName = replaceCentralBuild(stageName);
28+
}
29+
return stageName
30+
}
31+
32+
private String replaceCentralBuild(String stageName) {
33+
return CENTRAL_BUILD.equals(stageName) ? BUILD : stageName;
2134
}
2235

2336
static String getTechnicalStageName(Script step) {

0 commit comments

Comments
 (0)