1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-04 04:07:16 +02:00

AAKaaS: 2 Check Product Version (#2037)

* adding my steps

* messy step

* Update abapEnvironmentAssembly.go

* clean up

* change yaml

* corrections

* Update cloudFoundryDeploy.go

* update

* delete simulation step

* remove simulate

* Update PiperGoUtils.groovy

* Update PiperGoUtils.groovy

* Update CommonStepsTest.groovy

* add docu

* Update abapEnvironmentAssembly.md

* changes due to PR

* Update .gitignore

* b

* CV list

* Update abapEnvironmentAssembly.go

* testing with simulation

* Update abapEnvironmentAssembly.go

* remove simulation

* renaming

* Update mkdocs.yml

* moving service key to yaml and fixing code climate

* Update abapEnvironmentAssemblePackages.go

* Update abapEnvironmentAssemblePackages.go

* Update abapEnvironmentAssemblePackages.go

* Update abapEnvironmentAssemblePackages.go

* change input

* Update abapEnvironmentAssemblePackages.go

* change json tag

* fixed error handling

* documentation

* Update abapEnvironmentAssemblePackages.md

* Update abapEnvironmentAssemblePackages.md

* fixing code climate issues

* fixing code climate issues

* Update abapEnvironmentAssemblePackages.yaml

* fixing code climate issues

* Update abapEnvironmentAssemblePackages.yaml

* adding unittests

* adding unittests and improved logging

* yaml -> json

* change scope of cfServiceKeyName

* correct indentation

* Update CommonStepsTest.groovy

* maintain correct step order

* AAKaaS CheckPV step

* AAKaaS CheckPV step #2

* AAKaaS CheckPV step #3

* AAKaaS CheckPV step #4

* AAKaaS CheckPV step #5

* Update resources/metadata/abapAddonAssemblyKitCheckCVs.yaml

Co-authored-by: Daniel Mieg <56156797+DanielMieg@users.noreply.github.com>

* Update resources/metadata/abapAddonAssemblyKitCheckPV.yaml

Co-authored-by: Daniel Mieg <56156797+DanielMieg@users.noreply.github.com>

* Update resources/metadata/abapAddonAssemblyKitCheckPV.yaml

Co-authored-by: Daniel Mieg <56156797+DanielMieg@users.noreply.github.com>

* Update resources/metadata/abapAddonAssemblyKitCheckCVs.yaml

Co-authored-by: Daniel Mieg <56156797+DanielMieg@users.noreply.github.com>

* AAKaaS CheckPV step #6

Co-authored-by: rosemarieB <45030247+rosemarieB@users.noreply.github.com>
Co-authored-by: Daniel Mieg <56156797+DanielMieg@users.noreply.github.com>
Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>
This commit is contained in:
tiloKo 2020-09-17 15:56:14 +02:00 committed by GitHub
parent 2a776ba7eb
commit 427f78b3ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 569 additions and 21 deletions

View File

@ -40,7 +40,7 @@ func runAbapAddonAssemblyKitCheckCVs(config *abapAddonAssemblyKitCheckCVsOptions
conn.InitAAKaaS(config.AbapAddonAssemblyKitEndpoint, config.Username, config.Password, client)
for i := range addonDescriptor.Repositories {
var c cv
var c componentVersion
c.initCV(addonDescriptor.Repositories[i], *conn)
err := c.validate()
if err != nil {
@ -60,40 +60,40 @@ func combineYAMLRepositoriesWithCPEProduct(addonDescriptor abaputils.AddonDescri
return addonDescriptorFromCPE
}
func (c *cv) initCV(repo abaputils.Repository, conn abapbuild.Connector) {
func (c *componentVersion) initCV(repo abaputils.Repository, conn abapbuild.Connector) {
c.Connector = conn
c.Name = repo.Name
c.VersionYAML = repo.VersionYAML
}
func (c *cv) copyFieldsToRepo(initialRepo *abaputils.Repository) {
func (c *componentVersion) copyFieldsToRepo(initialRepo *abaputils.Repository) {
initialRepo.Version = c.Version
initialRepo.SpLevel = c.SpLevel
initialRepo.PatchLevel = c.PatchLevel
}
func (c *cv) validate() error {
func (c *componentVersion) validate() error {
log.Entry().Infof("Validate component %s version %s and resolve version", c.Name, c.VersionYAML)
appendum := "/odata/aas_ocs_package/ValidateComponentVersion?Name='" + c.Name + "'&Version='" + c.VersionYAML + "'"
body, err := c.Connector.Get(appendum)
if err != nil {
return err
}
var jCV jsonCV
var jCV jsonComponentVersion
json.Unmarshal(body, &jCV)
c.Name = jCV.CV.Name
c.Version = jCV.CV.Version
c.SpLevel = jCV.CV.SpLevel
c.PatchLevel = jCV.CV.PatchLevel
c.Name = jCV.ComponentVersion.Name
c.Version = jCV.ComponentVersion.Version
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)
return nil
}
type jsonCV struct {
CV *cv `json:"d"`
type jsonComponentVersion struct {
ComponentVersion *componentVersion `json:"d"`
}
type cv struct {
type componentVersion struct {
abapbuild.Connector
Name string `json:"Name"`
VersionYAML string

View File

@ -112,8 +112,8 @@ It resolves the dotted version string into version, support package level and pa
func addAbapAddonAssemblyKitCheckCVsFlags(cmd *cobra.Command, stepConfig *abapAddonAssemblyKitCheckCVsOptions) {
cmd.Flags().StringVar(&stepConfig.AbapAddonAssemblyKitEndpoint, "abapAddonAssemblyKitEndpoint", os.Getenv("PIPER_abapAddonAssemblyKitEndpoint"), "Base URL to the Addon Assembly Kit as a Service (AAKaaS) system")
cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User for the Addon Assembly Kit as a Service System (AAKaaS)")
cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password the Addon Assembly Kit as a Service System (AAKaaS)")
cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User for the Addon Assembly Kit as a Service (AAKaaS) system")
cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password for the Addon Assembly Kit as a Service (AAKaaS) system")
cmd.Flags().StringVar(&stepConfig.AddonDescriptorFileName, "addonDescriptorFileName", `addon.yml`, "File name of the YAML file which describes the Product Version and corresponding Software Component Versions")
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")

View File

@ -76,7 +76,7 @@ func TestInitCV(t *testing.T) {
Name: "/DRNMSPC/COMP01",
VersionYAML: "1.2.3",
}
var c cv
var c componentVersion
c.initCV(repo, *conn)
assert.Equal(t, "/DRNMSPC/COMP01", c.Name)
assert.Equal(t, "1.2.3", c.VersionYAML)
@ -89,7 +89,7 @@ func TestValidateCV(t *testing.T) {
conn.Client = &abaputils.ClientMock{
Body: responseCheckCVs,
}
c := cv{
c := componentVersion{
Connector: *conn,
Name: "/DRNMSPC/COMP01",
VersionYAML: "1.2.3",
@ -108,7 +108,7 @@ func TestValidateCV(t *testing.T) {
Body: "ErrorBody",
Error: errors.New("Validation failed"),
}
c := cv{
c := componentVersion{
Connector: *conn,
Name: "/DRNMSPC/COMP01",
VersionYAML: "1.2.3",
@ -127,7 +127,7 @@ func TestCopyFieldsCV(t *testing.T) {
Name: "/DRNMSPC/COMP01",
VersionYAML: "1.2.3",
}
var c cv
var c componentVersion
c.Version = "0001"
c.SpLevel = "0002"
c.PatchLevel = "0003"

View File

@ -0,0 +1,96 @@
package cmd
import (
"encoding/json"
abapbuild "github.com/SAP/jenkins-library/pkg/abap/build"
"github.com/SAP/jenkins-library/pkg/abaputils"
"github.com/SAP/jenkins-library/pkg/command"
piperhttp "github.com/SAP/jenkins-library/pkg/http"
"github.com/SAP/jenkins-library/pkg/log"
"github.com/SAP/jenkins-library/pkg/telemetry"
)
func abapAddonAssemblyKitCheckPV(config abapAddonAssemblyKitCheckPVOptions, telemetryData *telemetry.CustomData, cpe *abapAddonAssemblyKitCheckPVCommonPipelineEnvironment) {
// for command execution use Command
c := command.Command{}
// reroute command output to logging framework
c.Stdout(log.Writer())
c.Stderr(log.Writer())
client := piperhttp.Client{}
// error situations should stop execution through log.Entry().Fatal() call which leads to an os.Exit(1) in the end
err := runAbapAddonAssemblyKitCheckPV(&config, telemetryData, &client, cpe, abaputils.ReadAddonDescriptor)
if err != nil {
log.Entry().WithError(err).Fatal("step execution failed")
}
}
func runAbapAddonAssemblyKitCheckPV(config *abapAddonAssemblyKitCheckPVOptions, telemetryData *telemetry.CustomData, client piperhttp.Sender,
cpe *abapAddonAssemblyKitCheckPVCommonPipelineEnvironment, readAdoDescriptor abaputils.ReadAddonDescriptorType) error {
var addonDescriptorFromCPE abaputils.AddonDescriptor
json.Unmarshal([]byte(config.AddonDescriptor), &addonDescriptorFromCPE)
addonDescriptor, err := readAdoDescriptor(config.AddonDescriptorFileName)
addonDescriptor = combineYAMLRepositoriesWithCPEProduct(addonDescriptor, addonDescriptorFromCPE)
if err != nil {
return err
}
conn := new(abapbuild.Connector)
conn.InitAAKaaS(config.AbapAddonAssemblyKitEndpoint, config.Username, config.Password, client)
var p productVersion
p.init(addonDescriptor, *conn)
err = p.validate()
if err != nil {
return err
}
p.copyFieldsToRepo(&addonDescriptor)
log.Entry().Info("Write the resolved version to the CommonPipelineEnvironment")
toCPE, _ := json.Marshal(addonDescriptor)
cpe.abap.addonDescriptor = string(toCPE)
return nil
}
func (p *productVersion) init(desc abaputils.AddonDescriptor, conn abapbuild.Connector) {
p.Connector = conn
p.Name = desc.AddonProduct
p.VersionYAML = desc.AddonVersionYAML
}
func (p *productVersion) copyFieldsToRepo(initialAddonDescriptor *abaputils.AddonDescriptor) {
initialAddonDescriptor.AddonVersion = p.Version
initialAddonDescriptor.AddonSpsLevel = p.SpsLevel
initialAddonDescriptor.AddonPatchLevel = p.PatchLevel
}
func (p *productVersion) validate() error {
log.Entry().Infof("Validate product %s version %s and resolve version", p.Name, p.VersionYAML)
appendum := "/odata/aas_ocs_package/ValidateProductVersion?Name='" + p.Name + "'&Version='" + p.VersionYAML + "'"
body, err := p.Connector.Get(appendum)
if err != nil {
return err
}
var jPV jsonProductVersion
json.Unmarshal(body, &jPV)
p.Name = jPV.ProductVersion.Name
p.Version = jPV.ProductVersion.Version
p.SpsLevel = jPV.ProductVersion.SpsLevel
p.PatchLevel = jPV.ProductVersion.PatchLevel
log.Entry().Infof("Resolved version %s, spslevel %s, patchlevel %s", p.Version, p.SpsLevel, p.PatchLevel)
return nil
}
type jsonProductVersion struct {
ProductVersion *productVersion `json:"d"`
}
type productVersion struct {
abapbuild.Connector
Name string `json:"Name"`
VersionYAML string
Version string `json:"Version"`
SpsLevel string `json:"SpsLevel"`
PatchLevel string `json:"PatchLevel"`
TargetVectorID string
}

View File

@ -0,0 +1,186 @@
// Code generated by piper's step-generator. DO NOT EDIT.
package cmd
import (
"fmt"
"os"
"path/filepath"
"time"
"github.com/SAP/jenkins-library/pkg/config"
"github.com/SAP/jenkins-library/pkg/log"
"github.com/SAP/jenkins-library/pkg/piperenv"
"github.com/SAP/jenkins-library/pkg/telemetry"
"github.com/spf13/cobra"
)
type abapAddonAssemblyKitCheckPVOptions struct {
AbapAddonAssemblyKitEndpoint string `json:"abapAddonAssemblyKitEndpoint,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
AddonDescriptorFileName string `json:"addonDescriptorFileName,omitempty"`
AddonDescriptor string `json:"addonDescriptor,omitempty"`
}
type abapAddonAssemblyKitCheckPVCommonPipelineEnvironment struct {
abap struct {
addonDescriptor string
}
}
func (p *abapAddonAssemblyKitCheckPVCommonPipelineEnvironment) persist(path, resourceName string) {
content := []struct {
category string
name string
value string
}{
{category: "abap", name: "addonDescriptor", value: p.abap.addonDescriptor},
}
errCount := 0
for _, param := range content {
err := piperenv.SetResourceParameter(path, resourceName, filepath.Join(param.category, param.name), param.value)
if err != nil {
log.Entry().WithError(err).Error("Error persisting piper environment.")
errCount++
}
}
if errCount > 0 {
log.Entry().Fatal("failed to persist Piper environment")
}
}
// AbapAddonAssemblyKitCheckPVCommand This step checks the validity of a Addon Product Version.
func AbapAddonAssemblyKitCheckPVCommand() *cobra.Command {
const STEP_NAME = "abapAddonAssemblyKitCheckPV"
metadata := abapAddonAssemblyKitCheckPVMetadata()
var stepConfig abapAddonAssemblyKitCheckPVOptions
var startTime time.Time
var commonPipelineEnvironment abapAddonAssemblyKitCheckPVCommonPipelineEnvironment
var createAbapAddonAssemblyKitCheckPVCmd = &cobra.Command{
Use: STEP_NAME,
Short: "This step checks the validity of a Addon Product Version.",
Long: `This step checks whether the Addon Product Version in the addonDescriptorFileName does exist or is a valid successor of an existing Product Version.
It resolves the dotted version string into version, support package stack level and patch level and writes it to the commonPipelineEnvironment.`,
PreRunE: func(cmd *cobra.Command, _ []string) error {
startTime = time.Now()
log.SetStepName(STEP_NAME)
log.SetVerbose(GeneralConfig.Verbose)
path, _ := os.Getwd()
fatalHook := &log.FatalHook{CorrelationID: GeneralConfig.CorrelationID, Path: path}
log.RegisterHook(fatalHook)
err := PrepareConfig(cmd, &metadata, STEP_NAME, &stepConfig, config.OpenPiperFile)
if err != nil {
log.SetErrorCategory(log.ErrorConfiguration)
return err
}
log.RegisterSecret(stepConfig.Username)
log.RegisterSecret(stepConfig.Password)
if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 {
sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID)
log.RegisterHook(&sentryHook)
}
return nil
},
Run: func(_ *cobra.Command, _ []string) {
telemetryData := telemetry.CustomData{}
telemetryData.ErrorCode = "1"
handler := func() {
commonPipelineEnvironment.persist(GeneralConfig.EnvRootPath, "commonPipelineEnvironment")
telemetryData.Duration = fmt.Sprintf("%v", time.Since(startTime).Milliseconds())
telemetry.Send(&telemetryData)
}
log.DeferExitHandler(handler)
defer handler()
telemetry.Initialize(GeneralConfig.NoTelemetry, STEP_NAME)
abapAddonAssemblyKitCheckPV(stepConfig, &telemetryData, &commonPipelineEnvironment)
telemetryData.ErrorCode = "0"
log.Entry().Info("SUCCESS")
},
}
addAbapAddonAssemblyKitCheckPVFlags(createAbapAddonAssemblyKitCheckPVCmd, &stepConfig)
return createAbapAddonAssemblyKitCheckPVCmd
}
func addAbapAddonAssemblyKitCheckPVFlags(cmd *cobra.Command, stepConfig *abapAddonAssemblyKitCheckPVOptions) {
cmd.Flags().StringVar(&stepConfig.AbapAddonAssemblyKitEndpoint, "abapAddonAssemblyKitEndpoint", os.Getenv("PIPER_abapAddonAssemblyKitEndpoint"), "Base URL to the Addon Assembly Kit as a Service (AAKaaS) system")
cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User for the Addon Assembly Kit as a Service (AAKaaS) system")
cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password for the Addon Assembly Kit as a Service (AAKaaS) system")
cmd.Flags().StringVar(&stepConfig.AddonDescriptorFileName, "addonDescriptorFileName", `addon.yml`, "File name of the YAML file which describes the Product Version and corresponding Software Component Versions")
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.MarkFlagRequired("abapAddonAssemblyKitEndpoint")
cmd.MarkFlagRequired("username")
cmd.MarkFlagRequired("password")
cmd.MarkFlagRequired("addonDescriptorFileName")
}
// retrieve step metadata
func abapAddonAssemblyKitCheckPVMetadata() config.StepData {
var theMetaData = config.StepData{
Metadata: config.StepMetadata{
Name: "abapAddonAssemblyKitCheckPV",
Aliases: []config.Alias{},
},
Spec: config.StepSpec{
Inputs: config.StepInputs{
Parameters: []config.StepParameters{
{
Name: "abapAddonAssemblyKitEndpoint",
ResourceRef: []config.ResourceReference{},
Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"},
Type: "string",
Mandatory: true,
Aliases: []config.Alias{},
},
{
Name: "username",
ResourceRef: []config.ResourceReference{},
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
Type: "string",
Mandatory: true,
Aliases: []config.Alias{},
},
{
Name: "password",
ResourceRef: []config.ResourceReference{},
Scope: []string{"PARAMETERS"},
Type: "string",
Mandatory: true,
Aliases: []config.Alias{},
},
{
Name: "addonDescriptorFileName",
ResourceRef: []config.ResourceReference{},
Scope: []string{},
Type: "string",
Mandatory: true,
Aliases: []config.Alias{},
},
{
Name: "addonDescriptor",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "abap/addonDescriptor",
},
},
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
Type: "string",
Mandatory: false,
Aliases: []config.Alias{},
},
},
},
},
}
return theMetaData
}

View File

@ -0,0 +1,16 @@
package cmd
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestAbapAddonAssemblyKitCheckPVCommand(t *testing.T) {
testCmd := AbapAddonAssemblyKitCheckPVCommand()
// only high level testing performed - details are tested in step generation procedure
assert.Equal(t, "abapAddonAssemblyKitCheckPV", testCmd.Use, "command name incorrect")
}

View File

@ -0,0 +1,128 @@
package cmd
import (
"encoding/json"
"testing"
abapbuild "github.com/SAP/jenkins-library/pkg/abap/build"
"github.com/SAP/jenkins-library/pkg/abaputils"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
)
func TestCheckPVStep(t *testing.T) {
var config abapAddonAssemblyKitCheckPVOptions
var cpe abapAddonAssemblyKitCheckPVCommonPipelineEnvironment
client := &abaputils.ClientMock{
Body: responseCheckPV,
}
t.Run("step success", func(t *testing.T) {
config.AddonDescriptorFileName = "success"
err := runAbapAddonAssemblyKitCheckPV(&config, nil, client, &cpe, mockReadAddonDescriptor)
assert.NoError(t, err, "Did not expect error")
var addonDescriptorFinal abaputils.AddonDescriptor
json.Unmarshal([]byte(cpe.abap.addonDescriptor), &addonDescriptorFinal)
assert.Equal(t, "0003", addonDescriptorFinal.AddonVersion)
assert.Equal(t, "0002", addonDescriptorFinal.AddonSpsLevel)
assert.Equal(t, "0001", addonDescriptorFinal.AddonPatchLevel)
})
t.Run("step error - in ReadAddonDescriptor", func(t *testing.T) {
config.AddonDescriptorFileName = "failing"
err := runAbapAddonAssemblyKitCheckPV(&config, nil, client, &cpe, mockReadAddonDescriptor)
assert.Error(t, err, "Did expect error")
assert.Equal(t, err.Error(), "error in ReadAddonDescriptor")
})
t.Run("step error - in validate", func(t *testing.T) {
config.AddonDescriptorFileName = "success"
client := &abaputils.ClientMock{
Body: "ErrorBody",
Error: errors.New("error during validation"),
}
err := runAbapAddonAssemblyKitCheckPV(&config, nil, client, &cpe, mockReadAddonDescriptor)
assert.Error(t, err, "Did expect error")
})
}
func TestInitPV(t *testing.T) {
t.Run("test init", func(t *testing.T) {
conn := new(abapbuild.Connector)
conn.Client = &abaputils.ClientMock{}
prodvers := abaputils.AddonDescriptor{
AddonProduct: "/DRNMSPC/PRD01",
AddonVersionYAML: "3.2.1",
}
var pv productVersion
pv.init(prodvers, *conn)
assert.Equal(t, "/DRNMSPC/PRD01", pv.Name)
assert.Equal(t, "3.2.1", pv.VersionYAML)
})
}
func TestValidatePV(t *testing.T) {
conn := new(abapbuild.Connector)
t.Run("test validate - success", func(t *testing.T) {
conn.Client = &abaputils.ClientMock{
Body: responseCheckPV,
}
pv := productVersion{
Connector: *conn,
Name: "/DRNMSPC/PRD01",
VersionYAML: "3.2.1",
}
err := pv.validate()
assert.NoError(t, err)
assert.Equal(t, "0003", pv.Version)
assert.Equal(t, "0002", pv.SpsLevel)
assert.Equal(t, "0001", pv.PatchLevel)
})
t.Run("test validate - with error", func(t *testing.T) {
conn.Client = &abaputils.ClientMock{
Body: "ErrorBody",
Error: errors.New("Validation failed"),
}
pv := productVersion{
Connector: *conn,
Name: "/DRNMSPC/PRD01",
VersionYAML: "3.2.1",
}
err := pv.validate()
assert.Error(t, err)
assert.Equal(t, "", pv.Version)
assert.Equal(t, "", pv.SpsLevel)
assert.Equal(t, "", pv.PatchLevel)
})
}
func TestCopyFieldsPV(t *testing.T) {
t.Run("test copyFieldsToRepo", func(t *testing.T) {
prodVers := abaputils.AddonDescriptor{
AddonProduct: "/DRNMSPC/PRD01",
AddonVersionYAML: "1.2.3",
}
var pv productVersion
pv.Version = "0003"
pv.SpsLevel = "0002"
pv.PatchLevel = "0001"
pv.copyFieldsToRepo(&prodVers)
assert.Equal(t, "0003", prodVers.AddonVersion)
assert.Equal(t, "0002", prodVers.AddonSpsLevel)
assert.Equal(t, "0001", prodVers.AddonPatchLevel)
})
}
var responseCheckPV = `{
"d": {
"__metadata": {
"id": "https://W7Q.DMZWDF.SAP.CORP:443/odata/aas_ocs_package/ProductVersionSet(Name='%2FDRNMSPC%2FPRD01',Version='0001')",
"uri": "https://W7Q.DMZWDF.SAP.CORP:443/odata/aas_ocs_package/ProductVersionSet(Name='%2FDRNMSPC%2FPRD01',Version='0001')",
"type": "SSDA.AAS_ODATA_PACKAGE_SRV.ProductVersion"
},
"Name": "/DRNMSPC/PRD01",
"Version": "0003",
"SpsLevel": "0002",
"PatchLevel": "0001",
"Vendor": "",
"VendorType": ""
}
}`

View File

@ -106,6 +106,7 @@ func Execute() {
rootCmd.AddCommand(KanikoExecuteCommand())
rootCmd.AddCommand(AbapEnvironmentAssemblePackagesCommand())
rootCmd.AddCommand(AbapAddonAssemblyKitCheckCVsCommand())
rootCmd.AddCommand(AbapAddonAssemblyKitCheckPVCommand())
addRootFlags(rootCmd)
if err := rootCmd.Execute(); err != nil {

View File

@ -0,0 +1,48 @@
# ${docGenStepName}
## ${docGenDescription}
## Prerequisites
* The credentials to access the AAKaaS (e.g. S-User) must be stored in the Jenkins Credential Store
* The step needs an addon.yml containing information about the Product Version and corresponding Software Component Versions/Repositories. The addon.yml should look like this:
```yaml
addonProduct: /DMO/myAddonProduct
addonVersion: 3.1.4
addonUniqueID: myAddonId
customerID: $ID
repositories:
- name: /DMO/REPO_A
tag: v-1.0.1-build-0001
version: 1.0.1
- name: /DMO/REPO_B
tag: rel-2.1.1-build-0001
version: 2.1.1
```
## ${docGenParameters}
## ${docGenConfiguration}
## ${docJenkinsPluginDependencies}
## Examples
### Configuration in the config.yml
The recommended way to configure your pipeline is via the config.yml file. In this case, calling the step in the Jenkinsfile is reduced to one line:
```groovy
abapAddonAssemblyKitCheckPV script: this
```
The config.yml should look like this:
```yaml
steps:
abapAddonAssemblyKitCheckPV:
abapAddonAssemblyKitCredentialsId: 'abapAddonAssemblyKitCredentialsId',
abapAddonAssemblyKitEndpoint: 'https://myabapAddonAssemblyKitEndpoint.com',
addonDescriptorFileName: 'addon.yml'
```

View File

@ -50,6 +50,7 @@ nav:
- Extensibility: extensibility.md
- 'Library steps':
- abapAddonAssemblyKitCheckCVs: steps/abapAddonAssemblyKitCheckCVs.md
- abapAddonAssemblyKitCheckCVs: steps/abapAddonAssemblyKitCheckPV.md
- abapEnvironmentAssemblePackages: steps/abapEnvironmentAssemblePackages.md
- abapEnvironmentCheckoutBranch: steps/abapEnvironmentCheckoutBranch.md
- abapEnvironmentCloneGitRepo: steps/abapEnvironmentCloneGitRepo.md

View File

@ -9,7 +9,7 @@ spec:
inputs:
secrets:
- name: abapAddonAssemblyKitCredentialsId
description: Credential stored in Jenkins for Addon Assembly Kit as a Service System (AAKaaS)
description: Credential stored in Jenkins for the Addon Assembly Kit as a Service (AAKaaS) system
type: jenkins
params:
- name: abapAddonAssemblyKitEndpoint
@ -23,7 +23,7 @@ spec:
mandatory: true
- name: username
type: string
description: User for the Addon Assembly Kit as a Service System (AAKaaS)
description: User for the Addon Assembly Kit as a Service (AAKaaS) system
scope:
- PARAMETERS
- STAGES
@ -32,7 +32,7 @@ spec:
secret: true
- name: password
type: string
description: Password the Addon Assembly Kit as a Service System (AAKaaS)
description: Password for the Addon Assembly Kit as a Service (AAKaaS) system
scope:
- PARAMETERS
mandatory: true

View File

@ -0,0 +1,60 @@
metadata:
name: abapAddonAssemblyKitCheckPV
description: This step checks the validity of a Addon Product Version.
longDescription: |
This step checks whether the Addon Product Version in the addonDescriptorFileName does exist or is a valid successor of an existing Product Version.
It resolves the dotted version string into version, support package stack level and patch level and writes it to the commonPipelineEnvironment.
spec:
inputs:
secrets:
- name: abapAddonAssemblyKitCredentialsId
description: Credential stored in Jenkins for the Addon Assembly Kit as a Service (AAKaaS) system
type: jenkins
params:
- name: abapAddonAssemblyKitEndpoint
type: string
description: Base URL to the Addon Assembly Kit as a Service (AAKaaS) system
scope:
- PARAMETERS
- STAGES
- STEPS
- GENERAL
mandatory: true
- name: username
type: string
description: User for the Addon Assembly Kit as a Service (AAKaaS) system
scope:
- PARAMETERS
- STAGES
- STEPS
mandatory: true
secret: true
- name: password
type: string
description: Password for the Addon Assembly Kit as a Service (AAKaaS) system
scope:
- PARAMETERS
mandatory: true
secret: true
- name: addonDescriptorFileName
type: string
description: File name of the YAML file which describes the Product Version and corresponding Software Component Versions
mandatory: true
default: addon.yml
- name: addonDescriptor
type: string
description: Structure in the commonPipelineEnvironment containing information about the Product Version and corresponding Software Component Versions
mandatory: false
scope:
- PARAMETERS
- STAGES
- STEPS
resourceRef:
- name: commonPipelineEnvironment
param: abap/addonDescriptor
outputs:
resources:
- name: commonPipelineEnvironment
type: piperEnvironment
params:
- name: abap/addonDescriptor

View File

@ -107,6 +107,7 @@ public class CommonStepsTest extends BasePiperTest{
private static fieldRelatedWhitelist = [
'abapAddonAssemblyKitCheckCVs', //implementing new golang pattern without fields
'abapAddonAssemblyKitCheckPV', //implementing new golang pattern without fields
'abapEnvironmentAssemblePackages', //implementing new golang pattern without fields
'abapEnvironmentCheckoutBranch', //implementing new golang pattern without fields
'abapEnvironmentCloneGitRepo', //implementing new golang pattern without fields

View File

@ -0,0 +1,11 @@
import groovy.transform.Field
@Field String STEP_NAME = getClass().getName()
@Field String METADATA_FILE = 'metadata/abapAddonAssemblyKitCheckPV.yaml'
void call(Map parameters = [:]) {
List credentials = [
[type: 'usernamePassword', id: 'abapAddonAssemblyKitCredentialsId', env: ['PIPER_username', 'PIPER_password']]
]
piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials, false, false, true)
}