Skip to content

Commit 876f251

Browse files
authored
ABAP assemblePackages Alternative phase name (SAP#5469)
1 parent a827c93 commit 876f251

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

cmd/abapEnvironmentAssemblePackages.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func runAssemblePackages(config *abapEnvironmentAssemblePackagesOptions, com aba
8686
return nil, errConBuild
8787
}
8888

89-
builds, err := executeBuilds(addonDescriptor, *connBuild, time.Duration(config.MaxRuntimeInMinutes)*time.Minute, time.Duration(config.PollIntervalsInMilliseconds)*time.Millisecond)
89+
builds, err := executeBuilds(addonDescriptor, *connBuild, time.Duration(config.MaxRuntimeInMinutes)*time.Minute, time.Duration(config.PollIntervalsInMilliseconds)*time.Millisecond, config.AlternativePhaseName)
9090
if err != nil {
9191
return builds, errors.Wrap(err, "Starting Builds for Repositories with reserved AAKaaS packages failed")
9292
}
@@ -111,7 +111,7 @@ func runAssemblePackages(config *abapEnvironmentAssemblePackagesOptions, com aba
111111
return builds, nil
112112
}
113113

114-
func executeBuilds(addonDescriptor *abaputils.AddonDescriptor, conn abapbuild.Connector, maxRuntimeInMinutes time.Duration, pollInterval time.Duration) ([]buildWithRepository, error) {
114+
func executeBuilds(addonDescriptor *abaputils.AddonDescriptor, conn abapbuild.Connector, maxRuntimeInMinutes time.Duration, pollInterval time.Duration, altenativePhaseName string) ([]buildWithRepository, error) {
115115
var builds []buildWithRepository
116116

117117
for _, repo := range addonDescriptor.Repositories {
@@ -125,7 +125,7 @@ func executeBuilds(addonDescriptor *abaputils.AddonDescriptor, conn abapbuild.Co
125125

126126
if repo.Status == "P" {
127127
buildRepo.repo.InBuildScope = true
128-
err := buildRepo.start(addonDescriptor)
128+
err := buildRepo.start(addonDescriptor, altenativePhaseName)
129129
if err != nil {
130130
buildRepo.build.RunState = abapbuild.Failed
131131
buildRepo.repo.ErrorText = fmt.Sprint(err)
@@ -169,7 +169,7 @@ func (br *buildWithRepository) waitToBeFinished(maxRuntimeInMinutes time.Duratio
169169
}
170170
}
171171

172-
func (br *buildWithRepository) start(addonDescriptor *abaputils.AddonDescriptor) error {
172+
func (br *buildWithRepository) start(addonDescriptor *abaputils.AddonDescriptor, altenativePhaseName string) error {
173173
if br.repo.Name == "" || br.repo.Version == "" || br.repo.SpLevel == "" || br.repo.PackageType == "" || br.repo.PackageName == "" {
174174
return errors.New("Parameters missing. Please provide software component name, version, sp-level, packagetype and packagename")
175175
}
@@ -234,8 +234,15 @@ func (br *buildWithRepository) start(addonDescriptor *abaputils.AddonDescriptor)
234234
abapbuild.Value{ValueID: "ADDITIONAL_PIECELIST",
235235
Value: br.repo.AdditionalPiecelist})
236236
}
237-
phase := "BUILD_" + br.repo.PackageType
238-
log.Entry().Infof("Starting assembly of package %s", br.repo.PackageName)
237+
238+
var phase string
239+
if altenativePhaseName != "" {
240+
phase = altenativePhaseName
241+
} else {
242+
phase = "BUILD_" + br.repo.PackageType
243+
}
244+
245+
log.Entry().Infof("Starting assembly of package %s as %s", br.repo.PackageName, phase)
239246
return br.build.Start(phase, valuesInput)
240247
}
241248

cmd/abapEnvironmentAssemblePackages_generated.go

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/abapEnvironmentAssemblePackages_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestStartingInvalidInput(t *testing.T) {
7272
},
7373
},
7474
}
75-
builds, err := executeBuilds(&aD, *conn, time.Duration(0*time.Second), time.Duration(1*time.Millisecond))
75+
builds, err := executeBuilds(&aD, *conn, time.Duration(0*time.Second), time.Duration(1*time.Millisecond), "")
7676
assert.NoError(t, err)
7777
assert.Equal(t, 1, len(builds))
7878
assert.Equal(t, abapbuild.Failed, builds[0].build.RunState)

resources/metadata/abapEnvironmentAssemblePackages.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ spec:
140140
- STAGES
141141
- STEPS
142142
- GENERAL
143+
- name: alternativePhaseName
144+
description: overrides default phase name
145+
type: string
146+
mandatory: false
147+
scope:
148+
- PARAMETERS
149+
- STAGES
150+
- STEPS
151+
- GENERAL
143152
outputs:
144153
resources:
145154
- name: commonPipelineEnvironment

0 commit comments

Comments
 (0)