You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-09-16 09:26:22 +02:00
Enable classic cts (#3728)
* add useClassicCTS * debug output and unit test * unsaved fix * error logging * Update abapEnvironmentAssemblePackages.go * Update abapEnvironmentAssemblePackages.go * add general scope and remove logging * Update bfw.go * Update abapEnvironmentAssemblePackages.go * Update abapEnvironmentAssemblePackages.go * Update package.go * Update abapEnvironmentAssemblePackages.go * change scope and add certificates Co-authored-by: tiloKo <70266685+tiloKo@users.noreply.github.com>
This commit is contained in:
@@ -69,6 +69,7 @@ func (c *componentVersion) initCV(repo abaputils.Repository, conn abapbuild.Conn
|
||||
c.Name = repo.Name
|
||||
c.VersionYAML = repo.VersionYAML
|
||||
c.CommitID = repo.CommitID
|
||||
c.UseClassicCTS = repo.UseClassicCTS
|
||||
}
|
||||
|
||||
func (c *componentVersion) copyFieldsToRepo(initialRepo *abaputils.Repository) {
|
||||
@@ -93,8 +94,9 @@ func (c *componentVersion) validate() error {
|
||||
c.SpLevel = jCV.ComponentVersion.SpLevel
|
||||
c.PatchLevel = jCV.ComponentVersion.PatchLevel
|
||||
log.Entry().Infof("Resolved version %s, splevel %s, patchlevel %s", c.Version, c.SpLevel, c.PatchLevel)
|
||||
log.Entry().Infof("Using cCTS %t", c.UseClassicCTS)
|
||||
|
||||
if c.CommitID == "" {
|
||||
if !c.UseClassicCTS && c.CommitID == "" {
|
||||
return fmt.Errorf("CommitID missing in repo '%s' of the addon.yml", c.Name)
|
||||
}
|
||||
|
||||
@@ -107,10 +109,11 @@ type jsonComponentVersion struct {
|
||||
|
||||
type componentVersion struct {
|
||||
abapbuild.Connector
|
||||
Name string `json:"Name"`
|
||||
VersionYAML string
|
||||
Version string `json:"Version"`
|
||||
SpLevel string `json:"SpLevel"`
|
||||
PatchLevel string `json:"PatchLevel"`
|
||||
CommitID string
|
||||
Name string `json:"Name"`
|
||||
VersionYAML string
|
||||
Version string `json:"Version"`
|
||||
SpLevel string `json:"SpLevel"`
|
||||
PatchLevel string `json:"PatchLevel"`
|
||||
UseClassicCTS bool
|
||||
CommitID string
|
||||
}
|
||||
|
@@ -62,28 +62,30 @@ func checkAndCopyFieldsToRepositories(pckgWR []aakaas.PackageWithRepository) ([]
|
||||
|
||||
log.Entry().Infof("%-30v | %-20v | %-6v | %-40v | %-40v", pckgWR[i].Repo.Name, pckgWR[i].Package.PackageName, pckgWR[i].Package.Status, pckgWR[i].Repo.CommitID, pckgWR[i].Package.PredecessorCommitID)
|
||||
|
||||
if pckgWR[i].Package.Status == aakaas.PackageStatusReleased {
|
||||
//Ensure for Packages with Status R that CommitID of package = the one from addon.yml, beware of short commitID in addon.yml
|
||||
addonYAMLcommitIDLength := len(pckgWR[i].Repo.CommitID)
|
||||
if len(pckgWR[i].Package.CommitID) < addonYAMLcommitIDLength {
|
||||
return repos, errors.New("Provided CommitIDs have wrong length: " + pckgWR[i].Repo.CommitID + "(addon.yml) longer than the one from AAKaaS " + pckgWR[i].Package.CommitID)
|
||||
}
|
||||
packageCommitIDsubsting := pckgWR[i].Package.CommitID[0:addonYAMLcommitIDLength]
|
||||
if pckgWR[i].Repo.CommitID != packageCommitIDsubsting {
|
||||
log.Entry().Error("package " + pckgWR[i].Package.PackageName + " was already build but with commit " + pckgWR[i].Package.CommitID + ", not with " + pckgWR[i].Repo.CommitID)
|
||||
log.Entry().Error("If you want to build a new package make sure to increase the dotted-version-string in addon.yml")
|
||||
log.Entry().Error("If you do NOT want to build a new package enter the commitID " + pckgWR[i].Package.CommitID + " for software component " + pckgWR[i].Repo.Name + " in addon.yml")
|
||||
return repos, errors.New("commit of released package does not match with addon.yml")
|
||||
}
|
||||
} else if pckgWR[i].Package.PredecessorCommitID != "" {
|
||||
//Check for newly reserved packages which are to be build that CommitID from addon.yml != PreviousCommitID [this will result in an error as no delta can be calculated]
|
||||
addonYAMLcommitIDLength := len(pckgWR[i].Repo.CommitID)
|
||||
if len(pckgWR[i].Package.PredecessorCommitID) < addonYAMLcommitIDLength {
|
||||
return repos, errors.New("Provided CommitIDs have wrong length: " + pckgWR[i].Repo.CommitID + "(addon.yml) longer than the one from AAKaaS " + pckgWR[i].Package.CommitID)
|
||||
}
|
||||
packagePredecessorCommitIDsubsting := pckgWR[i].Package.PredecessorCommitID[0:addonYAMLcommitIDLength]
|
||||
if pckgWR[i].Repo.CommitID == packagePredecessorCommitIDsubsting {
|
||||
return repos, errors.New("CommitID of package " + pckgWR[i].Package.PackageName + " is the same as the one of the predecessor package. Make sure to change both the dotted-version-string AND the commitID in addon.yml")
|
||||
if !pckgWR[i].Repo.UseClassicCTS {
|
||||
if pckgWR[i].Package.Status == aakaas.PackageStatusReleased {
|
||||
//Ensure for Packages with Status R that CommitID of package = the one from addon.yml, beware of short commitID in addon.yml
|
||||
addonYAMLcommitIDLength := len(pckgWR[i].Repo.CommitID)
|
||||
if len(pckgWR[i].Package.CommitID) < addonYAMLcommitIDLength {
|
||||
return repos, errors.New("Provided CommitIDs have wrong length: " + pckgWR[i].Repo.CommitID + "(addon.yml) longer than the one from AAKaaS " + pckgWR[i].Package.CommitID)
|
||||
}
|
||||
packageCommitIDsubsting := pckgWR[i].Package.CommitID[0:addonYAMLcommitIDLength]
|
||||
if pckgWR[i].Repo.CommitID != packageCommitIDsubsting {
|
||||
log.Entry().Error("package " + pckgWR[i].Package.PackageName + " was already build but with commit " + pckgWR[i].Package.CommitID + ", not with " + pckgWR[i].Repo.CommitID)
|
||||
log.Entry().Error("If you want to build a new package make sure to increase the dotted-version-string in addon.yml")
|
||||
log.Entry().Error("If you do NOT want to build a new package enter the commitID " + pckgWR[i].Package.CommitID + " for software component " + pckgWR[i].Repo.Name + " in addon.yml")
|
||||
return repos, errors.New("commit of released package does not match with addon.yml")
|
||||
}
|
||||
} else if pckgWR[i].Package.PredecessorCommitID != "" {
|
||||
//Check for newly reserved packages which are to be build that CommitID from addon.yml != PreviousCommitID [this will result in an error as no delta can be calculated]
|
||||
addonYAMLcommitIDLength := len(pckgWR[i].Repo.CommitID)
|
||||
if len(pckgWR[i].Package.PredecessorCommitID) < addonYAMLcommitIDLength {
|
||||
return repos, errors.New("Provided CommitIDs have wrong length: " + pckgWR[i].Repo.CommitID + "(addon.yml) longer than the one from AAKaaS " + pckgWR[i].Package.CommitID)
|
||||
}
|
||||
packagePredecessorCommitIDsubsting := pckgWR[i].Package.PredecessorCommitID[0:addonYAMLcommitIDLength]
|
||||
if pckgWR[i].Repo.CommitID == packagePredecessorCommitIDsubsting {
|
||||
return repos, errors.New("CommitID of package " + pckgWR[i].Package.PackageName + " is the same as the one of the predecessor package. Make sure to change both the dotted-version-string AND the commitID in addon.yml")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -44,6 +44,7 @@ func runAbapEnvironmentAssembleConfirm(config *abapEnvironmentAssembleConfirmOpt
|
||||
connConfig.Password = config.Password
|
||||
connConfig.AddonDescriptor = config.AddonDescriptor
|
||||
connConfig.MaxRuntimeInMinutes = config.MaxRuntimeInMinutes
|
||||
connConfig.CertificateNames = config.CertificateNames
|
||||
|
||||
err := conn.InitBuildFramework(connConfig, com, client)
|
||||
if err != nil {
|
||||
|
@@ -18,16 +18,17 @@ import (
|
||||
)
|
||||
|
||||
type abapEnvironmentAssembleConfirmOptions struct {
|
||||
CfAPIEndpoint string `json:"cfApiEndpoint,omitempty"`
|
||||
CfOrg string `json:"cfOrg,omitempty"`
|
||||
CfSpace string `json:"cfSpace,omitempty"`
|
||||
CfServiceInstance string `json:"cfServiceInstance,omitempty"`
|
||||
CfServiceKeyName string `json:"cfServiceKeyName,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
AddonDescriptor string `json:"addonDescriptor,omitempty"`
|
||||
MaxRuntimeInMinutes int `json:"maxRuntimeInMinutes,omitempty"`
|
||||
CfAPIEndpoint string `json:"cfApiEndpoint,omitempty"`
|
||||
CfOrg string `json:"cfOrg,omitempty"`
|
||||
CfSpace string `json:"cfSpace,omitempty"`
|
||||
CfServiceInstance string `json:"cfServiceInstance,omitempty"`
|
||||
CfServiceKeyName string `json:"cfServiceKeyName,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
AddonDescriptor string `json:"addonDescriptor,omitempty"`
|
||||
MaxRuntimeInMinutes int `json:"maxRuntimeInMinutes,omitempty"`
|
||||
CertificateNames []string `json:"certificateNames,omitempty"`
|
||||
}
|
||||
|
||||
type abapEnvironmentAssembleConfirmCommonPipelineEnvironment struct {
|
||||
@@ -161,6 +162,7 @@ func addAbapEnvironmentAssembleConfirmFlags(cmd *cobra.Command, stepConfig *abap
|
||||
cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password for either the Cloud Foundry API or the Communication Arrangement for SAP_COM_0582")
|
||||
cmd.Flags().StringVar(&stepConfig.AddonDescriptor, "addonDescriptor", os.Getenv("PIPER_addonDescriptor"), "Structure in the commonPipelineEnvironment containing information about the Product Version and corresponding Software Component Versions")
|
||||
cmd.Flags().IntVar(&stepConfig.MaxRuntimeInMinutes, "maxRuntimeInMinutes", 360, "maximal runtime of the step")
|
||||
cmd.Flags().StringSliceVar(&stepConfig.CertificateNames, "certificateNames", []string{}, "certificates for the backend system, this certificates needs to be stored in .pipeline/trustStore")
|
||||
|
||||
cmd.MarkFlagRequired("username")
|
||||
cmd.MarkFlagRequired("password")
|
||||
@@ -230,7 +232,7 @@ func abapEnvironmentAssembleConfirmMetadata() config.StepData {
|
||||
{
|
||||
Name: "host",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
@@ -277,6 +279,15 @@ func abapEnvironmentAssembleConfirmMetadata() config.StepData {
|
||||
Aliases: []config.Alias{},
|
||||
Default: 360,
|
||||
},
|
||||
{
|
||||
Name: "certificateNames",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"},
|
||||
Type: "[]string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
Default: []string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
Containers: []config.Container{
|
||||
|
@@ -138,8 +138,8 @@ func (br *buildWithRepository) waitToBeFinished(maxRuntimeInMinutes time.Duratio
|
||||
}
|
||||
|
||||
func (br *buildWithRepository) start() error {
|
||||
if br.repo.Name == "" || br.repo.Version == "" || br.repo.SpLevel == "" || br.repo.Namespace == "" || br.repo.PackageType == "" || br.repo.PackageName == "" {
|
||||
return errors.New("Parameters missing. Please provide software component name, version, sp-level, namespace, packagetype and packagename")
|
||||
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")
|
||||
}
|
||||
valuesInput := abapbuild.Values{
|
||||
Values: []abapbuild.Value{
|
||||
@@ -151,10 +151,6 @@ func (br *buildWithRepository) start() error {
|
||||
ValueID: "CVERS",
|
||||
Value: br.repo.Name + "." + br.repo.Version + "." + br.repo.SpLevel,
|
||||
},
|
||||
{
|
||||
ValueID: "NAMESPACE",
|
||||
Value: br.repo.Namespace,
|
||||
},
|
||||
{
|
||||
ValueID: "PACKAGE_TYPE",
|
||||
Value: br.repo.PackageType,
|
||||
@@ -165,6 +161,16 @@ func (br *buildWithRepository) start() error {
|
||||
},
|
||||
},
|
||||
}
|
||||
if br.repo.Namespace != "" {
|
||||
valuesInput.Values = append(valuesInput.Values,
|
||||
abapbuild.Value{ValueID: "NAMESPACE",
|
||||
Value: br.repo.Namespace})
|
||||
}
|
||||
if br.repo.UseClassicCTS {
|
||||
valuesInput.Values = append(valuesInput.Values,
|
||||
abapbuild.Value{ValueID: "useClassicCTS",
|
||||
Value: "true"})
|
||||
}
|
||||
if br.repo.PredecessorCommitID != "" {
|
||||
valuesInput.Values = append(valuesInput.Values,
|
||||
abapbuild.Value{ValueID: "PREVIOUS_DELIVERY_COMMIT",
|
||||
@@ -228,7 +234,9 @@ func checkIfFailedAndPrintLogs(builds []buildWithRepository) error {
|
||||
log.Entry().Errorf("Assembly of %s failed", builds[i].repo.PackageName)
|
||||
buildFailed = true
|
||||
}
|
||||
builds[i].build.PrintLogs()
|
||||
if builds[i].build.BuildID != "" {
|
||||
builds[i].build.PrintLogs()
|
||||
}
|
||||
}
|
||||
if buildFailed {
|
||||
return errors.New("At least the assembly of one package failed")
|
||||
@@ -248,6 +256,7 @@ func initAssemblePackagesConnection(conn *abapbuild.Connector, config *abapEnvir
|
||||
connConfig.Password = config.Password
|
||||
connConfig.AddonDescriptor = config.AddonDescriptor
|
||||
connConfig.MaxRuntimeInMinutes = config.MaxRuntimeInMinutes
|
||||
connConfig.CertificateNames = config.CertificateNames
|
||||
|
||||
err := conn.InitBuildFramework(connConfig, com, client)
|
||||
if err != nil {
|
||||
|
@@ -18,17 +18,18 @@ import (
|
||||
)
|
||||
|
||||
type abapEnvironmentAssemblePackagesOptions struct {
|
||||
CfAPIEndpoint string `json:"cfApiEndpoint,omitempty"`
|
||||
CfOrg string `json:"cfOrg,omitempty"`
|
||||
CfSpace string `json:"cfSpace,omitempty"`
|
||||
CfServiceInstance string `json:"cfServiceInstance,omitempty"`
|
||||
CfServiceKeyName string `json:"cfServiceKeyName,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
AddonDescriptor string `json:"addonDescriptor,omitempty"`
|
||||
MaxRuntimeInMinutes int `json:"maxRuntimeInMinutes,omitempty"`
|
||||
PollIntervalsInMilliseconds int `json:"pollIntervalsInMilliseconds,omitempty"`
|
||||
CfAPIEndpoint string `json:"cfApiEndpoint,omitempty"`
|
||||
CfOrg string `json:"cfOrg,omitempty"`
|
||||
CfSpace string `json:"cfSpace,omitempty"`
|
||||
CfServiceInstance string `json:"cfServiceInstance,omitempty"`
|
||||
CfServiceKeyName string `json:"cfServiceKeyName,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
AddonDescriptor string `json:"addonDescriptor,omitempty"`
|
||||
MaxRuntimeInMinutes int `json:"maxRuntimeInMinutes,omitempty"`
|
||||
PollIntervalsInMilliseconds int `json:"pollIntervalsInMilliseconds,omitempty"`
|
||||
CertificateNames []string `json:"certificateNames,omitempty"`
|
||||
}
|
||||
|
||||
type abapEnvironmentAssemblePackagesCommonPipelineEnvironment struct {
|
||||
@@ -164,6 +165,7 @@ func addAbapEnvironmentAssemblePackagesFlags(cmd *cobra.Command, stepConfig *aba
|
||||
cmd.Flags().StringVar(&stepConfig.AddonDescriptor, "addonDescriptor", os.Getenv("PIPER_addonDescriptor"), "Structure in the commonPipelineEnvironment containing information about the Product Version and corresponding Software Component Versions")
|
||||
cmd.Flags().IntVar(&stepConfig.MaxRuntimeInMinutes, "maxRuntimeInMinutes", 360, "maximal runtime of the step in minutes")
|
||||
cmd.Flags().IntVar(&stepConfig.PollIntervalsInMilliseconds, "pollIntervalsInMilliseconds", 60000, "wait time in milliseconds till next status request in the backend system")
|
||||
cmd.Flags().StringSliceVar(&stepConfig.CertificateNames, "certificateNames", []string{}, "certificates for the backend system, this certificates needs to be stored in .pipeline/trustStore")
|
||||
|
||||
cmd.MarkFlagRequired("username")
|
||||
cmd.MarkFlagRequired("password")
|
||||
@@ -234,7 +236,7 @@ func abapEnvironmentAssemblePackagesMetadata() config.StepData {
|
||||
{
|
||||
Name: "host",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
@@ -290,6 +292,15 @@ func abapEnvironmentAssemblePackagesMetadata() config.StepData {
|
||||
Aliases: []config.Alias{},
|
||||
Default: 60000,
|
||||
},
|
||||
{
|
||||
Name: "certificateNames",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"},
|
||||
Type: "[]string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
Default: []string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
Containers: []config.Container{
|
||||
|
@@ -111,6 +111,9 @@ func (p *Package) GetPackageAndNamespace() error {
|
||||
}
|
||||
p.Status = jPck.Package.Status
|
||||
p.Namespace = jPck.Package.Namespace
|
||||
if p.Namespace == "//" {
|
||||
p.Namespace = ""
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@@ -177,7 +177,7 @@ func (b *Build) Start(phase string, inputValues Values) error {
|
||||
|
||||
body, err := b.Connector.Post("/builds", importBody)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Wrap(err, "Start of build failed: "+string(body))
|
||||
}
|
||||
|
||||
var jBuild jsonBuild
|
||||
|
@@ -37,6 +37,7 @@ type AddonDescriptor struct {
|
||||
// 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"`
|
||||
|
@@ -26,6 +26,7 @@ func TestAddonDescriptorNew(t *testing.T) {
|
||||
assert.Equal(t, "JEK8S273S", addonDescriptor.Repositories[1].CommitID)
|
||||
assert.Equal(t, "FR", addonDescriptor.Repositories[1].Languages[2])
|
||||
assert.Equal(t, `ISO-DEENFR`, addonDescriptor.Repositories[1].GetAakAasLanguageVector())
|
||||
assert.Equal(t, true, addonDescriptor.Repositories[1].UseClassicCTS)
|
||||
})
|
||||
|
||||
t.Run("getRepositoriesInBuildScope", func(t *testing.T) {
|
||||
@@ -59,7 +60,8 @@ repositories:
|
||||
languages:
|
||||
- DE
|
||||
- EN
|
||||
- FR`
|
||||
- FR
|
||||
useClassicCTS: true`
|
||||
|
||||
func TestReadAddonDescriptor(t *testing.T) {
|
||||
t.Run("Test: success case", func(t *testing.T) {
|
||||
|
@@ -78,6 +78,7 @@ spec:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- GENERAL
|
||||
- name: username
|
||||
type: string
|
||||
description: User for either the Cloud Foundry API or the Communication Arrangement for SAP_COM_0582
|
||||
@@ -116,6 +117,15 @@ spec:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- name: certificateNames
|
||||
type: "[]string"
|
||||
description: certificates for the backend system, this certificates needs to be stored in .pipeline/trustStore
|
||||
mandatory: false
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- GENERAL
|
||||
outputs:
|
||||
resources:
|
||||
- name: commonPipelineEnvironment
|
||||
|
@@ -79,6 +79,7 @@ spec:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- GENERAL
|
||||
- name: username
|
||||
type: string
|
||||
description: User for either the Cloud Foundry API or the Communication Arrangement for SAP_COM_0582
|
||||
@@ -126,6 +127,15 @@ spec:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- name: certificateNames
|
||||
type: "[]string"
|
||||
description: certificates for the backend system, this certificates needs to be stored in .pipeline/trustStore
|
||||
mandatory: false
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- GENERAL
|
||||
outputs:
|
||||
resources:
|
||||
- name: commonPipelineEnvironment
|
||||
|
Reference in New Issue
Block a user