mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-02-19 19:44:27 +02:00
Provide addonDescriptor to build System (#4914)
This commit is contained in:
parent
7d9fc6aee4
commit
0aac69625e
@ -50,7 +50,7 @@ func runAbapEnvironmentAssemblePackages(config *abapEnvironmentAssemblePackagesO
|
||||
return errors.Wrap(err, "Reading AddonDescriptor failed [Make sure abapAddonAssemblyKit...CheckCVs|CheckPV|ReserveNextPackages steps have been run before]")
|
||||
}
|
||||
|
||||
builds, err := executeBuilds(addonDescriptor.Repositories, *connBuild, time.Duration(config.MaxRuntimeInMinutes)*time.Minute, time.Duration(config.PollIntervalsInMilliseconds)*time.Millisecond)
|
||||
builds, err := executeBuilds(addonDescriptor, *connBuild, time.Duration(config.MaxRuntimeInMinutes)*time.Minute, time.Duration(config.PollIntervalsInMilliseconds)*time.Millisecond)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Starting Builds for Repositories with reserved AAKaaS packages failed")
|
||||
}
|
||||
@ -84,10 +84,10 @@ func runAbapEnvironmentAssemblePackages(config *abapEnvironmentAssemblePackagesO
|
||||
return nil
|
||||
}
|
||||
|
||||
func executeBuilds(repos []abaputils.Repository, conn abapbuild.Connector, maxRuntimeInMinutes time.Duration, pollInterval time.Duration) ([]buildWithRepository, error) {
|
||||
func executeBuilds(addonDescriptor *abaputils.AddonDescriptor, conn abapbuild.Connector, maxRuntimeInMinutes time.Duration, pollInterval time.Duration) ([]buildWithRepository, error) {
|
||||
var builds []buildWithRepository
|
||||
|
||||
for _, repo := range repos {
|
||||
for _, repo := range addonDescriptor.Repositories {
|
||||
|
||||
buildRepo := buildWithRepository{
|
||||
build: abapbuild.Build{
|
||||
@ -98,7 +98,7 @@ func executeBuilds(repos []abaputils.Repository, conn abapbuild.Connector, maxRu
|
||||
|
||||
if repo.Status == "P" {
|
||||
buildRepo.repo.InBuildScope = true
|
||||
err := buildRepo.start()
|
||||
err := buildRepo.start(addonDescriptor)
|
||||
if err != nil {
|
||||
buildRepo.build.RunState = abapbuild.Failed
|
||||
log.Entry().Error(err)
|
||||
@ -140,7 +140,7 @@ func (br *buildWithRepository) waitToBeFinished(maxRuntimeInMinutes time.Duratio
|
||||
}
|
||||
}
|
||||
|
||||
func (br *buildWithRepository) start() error {
|
||||
func (br *buildWithRepository) start(addonDescriptor *abaputils.AddonDescriptor) error {
|
||||
if br.repo.Name == "" || br.repo.Version == "" || br.repo.SpLevel == "" || br.repo.PackageType == "" || br.repo.PackageName == "" {
|
||||
return errors.New("Parameters missing. Please provide software component name, version, sp-level, packagetype and packagename")
|
||||
}
|
||||
@ -166,6 +166,10 @@ func (br *buildWithRepository) start() error {
|
||||
ValueID: "PACKAGE_NAME_" + br.repo.PackageType,
|
||||
Value: br.repo.PackageName,
|
||||
},
|
||||
{
|
||||
ValueID: "addonDescriptor",
|
||||
Value: addonDescriptor.AsReducedJson(),
|
||||
},
|
||||
},
|
||||
}
|
||||
if br.repo.Namespace != "" {
|
||||
|
@ -64,13 +64,15 @@ func TestStartingInvalidInput(t *testing.T) {
|
||||
conn := new(abapbuild.Connector)
|
||||
conn.Client = client
|
||||
conn.Header = make(map[string][]string)
|
||||
var repos []abaputils.Repository
|
||||
repo := abaputils.Repository{
|
||||
Name: "RepoA",
|
||||
Status: "P",
|
||||
aD := abaputils.AddonDescriptor{
|
||||
Repositories: []abaputils.Repository{
|
||||
{
|
||||
Name: "RepoA",
|
||||
Status: "P",
|
||||
},
|
||||
},
|
||||
}
|
||||
repos = append(repos, repo)
|
||||
builds, err := executeBuilds(repos, *conn, time.Duration(0*time.Second), time.Duration(1*time.Millisecond))
|
||||
builds, err := executeBuilds(&aD, *conn, time.Duration(0*time.Second), time.Duration(1*time.Millisecond))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, len(builds))
|
||||
assert.Equal(t, abapbuild.Failed, builds[0].build.RunState)
|
||||
@ -95,7 +97,7 @@ func TestStep(t *testing.T) {
|
||||
|
||||
err := runAbapEnvironmentAssemblePackages(config, nil, autils, &mock.FilesMock{}, &client, cpe)
|
||||
assert.NoError(t, err)
|
||||
assert.Contains(t, cpe.abap.addonDescriptor, `"InBuildScope":false`)
|
||||
assert.NotContains(t, cpe.abap.addonDescriptor, `"InBuildScope"`)
|
||||
})
|
||||
t.Run("abapEnvironmentAssemblePackages: build", func(t *testing.T) {
|
||||
config := &abapEnvironmentAssemblePackagesOptions{
|
||||
|
@ -26,34 +26,34 @@ import (
|
||||
// AddonDescriptor contains fields about the addonProduct
|
||||
type AddonDescriptor struct {
|
||||
AddonProduct string `json:"addonProduct"`
|
||||
AddonVersionYAML string `json:"addonVersion"`
|
||||
AddonVersionYAML string `json:"addonVersion,omitempty"`
|
||||
AddonVersion string `json:"addonVersionAAK"`
|
||||
AddonSpsLevel string
|
||||
AddonPatchLevel string
|
||||
TargetVectorID string
|
||||
TargetVectorID string `json:",omitempty"`
|
||||
Repositories []Repository `json:"repositories"`
|
||||
}
|
||||
|
||||
// Repository contains fields for the repository/component version
|
||||
type Repository struct {
|
||||
Name string `json:"name"`
|
||||
UseClassicCTS bool `json:"useClassicCTS"`
|
||||
Tag string `json:"tag"`
|
||||
Branch string `json:"branch"`
|
||||
CommitID string `json:"commitID"`
|
||||
VersionYAML string `json:"version"`
|
||||
UseClassicCTS bool `json:"useClassicCTS,omitempty"`
|
||||
Tag string `json:"tag,omitempty"`
|
||||
Branch string `json:"branch,omitempty"`
|
||||
CommitID string `json:"commitID,omitempty"`
|
||||
VersionYAML string `json:"version,omitempty"`
|
||||
Version string `json:"versionAAK"`
|
||||
AdditionalPiecelist string `json:"additionalPiecelist"`
|
||||
PackageName string
|
||||
PackageType string
|
||||
AdditionalPiecelist string `json:"additionalPiecelist,omitempty"`
|
||||
PackageName string `json:",omitempty"`
|
||||
PackageType string `json:",omitempty"`
|
||||
SpLevel string
|
||||
PatchLevel string
|
||||
PredecessorCommitID string
|
||||
Status string
|
||||
Namespace string
|
||||
SarXMLFilePath string
|
||||
Languages []string `json:"languages"`
|
||||
InBuildScope bool
|
||||
PredecessorCommitID string `json:",omitempty"`
|
||||
Status string `json:",omitempty"`
|
||||
Namespace string `json:",omitempty"`
|
||||
SarXMLFilePath string `json:",omitempty"`
|
||||
Languages []string `json:"languages,omitempty"`
|
||||
InBuildScope bool `json:",omitempty"`
|
||||
}
|
||||
|
||||
// ReadAddonDescriptorType is the type for ReadAddonDescriptor for mocking
|
||||
@ -182,3 +182,22 @@ func (me *AddonDescriptor) GetRepositoriesInBuildScope() []Repository {
|
||||
}
|
||||
return RepositoriesInBuildScope
|
||||
}
|
||||
|
||||
func (me *AddonDescriptor) AsReducedJson() string {
|
||||
input := AddonDescriptor{
|
||||
AddonProduct: me.AddonProduct,
|
||||
AddonVersion: me.AddonVersion,
|
||||
AddonSpsLevel: me.AddonSpsLevel,
|
||||
AddonPatchLevel: me.AddonPatchLevel,
|
||||
}
|
||||
for _, repo := range me.Repositories {
|
||||
input.Repositories = append(input.Repositories, Repository{
|
||||
Name: repo.Name,
|
||||
Version: repo.Version,
|
||||
SpLevel: repo.SpLevel,
|
||||
PatchLevel: repo.PatchLevel,
|
||||
})
|
||||
}
|
||||
|
||||
return input.AsJSONstring()
|
||||
}
|
||||
|
@ -40,6 +40,9 @@ func TestAddonDescriptorNew(t *testing.T) {
|
||||
assert.Equal(t, "/DMO/REPO_B", repos[0].Name)
|
||||
})
|
||||
|
||||
t.Run("AsReducedJson", func(t *testing.T) {
|
||||
assert.NotContains(t, "commitID", addonDescriptor.AsReducedJson())
|
||||
})
|
||||
}
|
||||
|
||||
var TestAddonDescriptorYAML = `---
|
||||
|
Loading…
x
Reference in New Issue
Block a user