mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-04-17 12:06:28 +02:00
Adding new step for abap Enviroment Assembly Confirm (#2586)
* Adding new abap Assembly Confirm * Update abapEnvironmentAssembleConfirm.go * Add generated objects Co-authored-by: tiloKo <70266685+tiloKo@users.noreply.github.com>
This commit is contained in:
parent
8c030784e1
commit
e9a93ed384
122
cmd/abapEnvironmentAssembleConfirm.go
Normal file
122
cmd/abapEnvironmentAssembleConfirm.go
Normal file
@ -0,0 +1,122 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
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"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func abapEnvironmentAssembleConfirm(config abapEnvironmentAssembleConfirmOptions, telemetryData *telemetry.CustomData, cpe *abapEnvironmentAssembleConfirmCommonPipelineEnvironment) {
|
||||
// for command execution use Command
|
||||
c := command.Command{}
|
||||
// reroute command output to logging framework
|
||||
c.Stdout(log.Writer())
|
||||
c.Stderr(log.Writer())
|
||||
|
||||
var autils = abaputils.AbapUtils{
|
||||
Exec: &c,
|
||||
}
|
||||
|
||||
client := piperhttp.Client{}
|
||||
err := runAbapEnvironmentAssembleConfirm(&config, telemetryData, &autils, &client, cpe)
|
||||
if err != nil {
|
||||
log.Entry().WithError(err).Fatal("step execution failed")
|
||||
}
|
||||
}
|
||||
|
||||
func runAbapEnvironmentAssembleConfirm(config *abapEnvironmentAssembleConfirmOptions, telemetryData *telemetry.CustomData, com abaputils.Communication, client piperhttp.Sender, cpe *abapEnvironmentAssembleConfirmCommonPipelineEnvironment) error {
|
||||
conn := new(abapbuild.Connector)
|
||||
var connConfig abapbuild.ConnectorConfiguration
|
||||
connConfig.CfAPIEndpoint = config.CfAPIEndpoint
|
||||
connConfig.CfOrg = config.CfOrg
|
||||
connConfig.CfSpace = config.CfSpace
|
||||
connConfig.CfServiceInstance = config.CfServiceInstance
|
||||
connConfig.CfServiceKeyName = config.CfServiceKeyName
|
||||
connConfig.Host = config.Host
|
||||
connConfig.Username = config.Username
|
||||
connConfig.Password = config.Password
|
||||
connConfig.AddonDescriptor = config.AddonDescriptor
|
||||
connConfig.MaxRuntimeInMinutes = config.MaxRuntimeInMinutes
|
||||
|
||||
err := conn.InitBuildFramework(connConfig, com, client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var addonDescriptor abaputils.AddonDescriptor
|
||||
err = json.Unmarshal([]byte(config.AddonDescriptor), &addonDescriptor)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
delayBetweenPostsInSeconds := time.Duration(3 * time.Second)
|
||||
builds, err := startingConfirm(addonDescriptor.Repositories, *conn, delayBetweenPostsInSeconds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
maxRuntimeInMinutes := time.Duration(config.MaxRuntimeInMinutes) * time.Minute
|
||||
pollIntervalsInSeconds := time.Duration(60 * time.Second)
|
||||
err = polling(builds, maxRuntimeInMinutes, pollIntervalsInSeconds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = checkIfFailedAndPrintLogs(builds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func startingConfirm(repos []abaputils.Repository, conn abapbuild.Connector, delayBetweenPostsInSeconds time.Duration) ([]buildWithRepository, error) {
|
||||
var builds []buildWithRepository
|
||||
var buildsAlreadyReleased []buildWithRepository
|
||||
for _, repo := range repos {
|
||||
assemblyBuild := abapbuild.Build{
|
||||
Connector: conn,
|
||||
}
|
||||
buildRepo := buildWithRepository{
|
||||
build: assemblyBuild,
|
||||
repo: repo,
|
||||
}
|
||||
if repo.Status == "P" {
|
||||
err := buildRepo.startConfirm()
|
||||
if err != nil {
|
||||
return builds, err
|
||||
}
|
||||
builds = append(builds, buildRepo)
|
||||
} else {
|
||||
log.Entry().Infof("Packages %s is in status '%s'. No need assembly done, no need to confirm", repo.PackageName, repo.Status)
|
||||
buildsAlreadyReleased = append(buildsAlreadyReleased, buildRepo)
|
||||
}
|
||||
|
||||
//as batch events in the ABAP Backend need a little time
|
||||
time.Sleep(delayBetweenPostsInSeconds)
|
||||
}
|
||||
return builds, nil
|
||||
}
|
||||
|
||||
func (b *buildWithRepository) startConfirm() error {
|
||||
if b.repo.Name == "" || b.repo.Namespace == "" || b.repo.PackageName == "" {
|
||||
return errors.New("Parameters missing. Please provide software component name, namespace and packagename")
|
||||
}
|
||||
valuesInput := abapbuild.Values{
|
||||
Values: []abapbuild.Value{
|
||||
{
|
||||
ValueID: "SWC",
|
||||
Value: b.repo.Name,
|
||||
},
|
||||
{
|
||||
ValueID: "SSDC-delta",
|
||||
Value: b.repo.Namespace + b.repo.PackageName,
|
||||
},
|
||||
},
|
||||
}
|
||||
phase := "BUILD_CONFIRM"
|
||||
log.Entry().Infof("Starting confirmation of package %s", b.repo.PackageName)
|
||||
return b.build.Start(phase, valuesInput)
|
||||
}
|
252
cmd/abapEnvironmentAssembleConfirm_generated.go
Normal file
252
cmd/abapEnvironmentAssembleConfirm_generated.go
Normal file
@ -0,0 +1,252 @@
|
||||
// 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 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"`
|
||||
}
|
||||
|
||||
type abapEnvironmentAssembleConfirmCommonPipelineEnvironment struct {
|
||||
abap struct {
|
||||
addonDescriptor string
|
||||
}
|
||||
}
|
||||
|
||||
func (p *abapEnvironmentAssembleConfirmCommonPipelineEnvironment) persist(path, resourceName string) {
|
||||
content := []struct {
|
||||
category string
|
||||
name string
|
||||
value interface{}
|
||||
}{
|
||||
{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")
|
||||
}
|
||||
}
|
||||
|
||||
// AbapEnvironmentAssembleConfirmCommand Confirm the Delivery of Assembly for installation, support package or patch in SAP Cloud Platform ABAP Environment system
|
||||
func AbapEnvironmentAssembleConfirmCommand() *cobra.Command {
|
||||
const STEP_NAME = "abapEnvironmentAssembleConfirm"
|
||||
|
||||
metadata := abapEnvironmentAssembleConfirmMetadata()
|
||||
var stepConfig abapEnvironmentAssembleConfirmOptions
|
||||
var startTime time.Time
|
||||
var commonPipelineEnvironment abapEnvironmentAssembleConfirmCommonPipelineEnvironment
|
||||
|
||||
var createAbapEnvironmentAssembleConfirmCmd = &cobra.Command{
|
||||
Use: STEP_NAME,
|
||||
Short: "Confirm the Delivery of Assembly for installation, support package or patch in SAP Cloud Platform ABAP Environment system",
|
||||
Long: `This step confirms the assemblies of provided [installations, support packages or patches] in SAP Cloud Platform ABAP Environment system`,
|
||||
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() {
|
||||
config.RemoveVaultSecretFiles()
|
||||
commonPipelineEnvironment.persist(GeneralConfig.EnvRootPath, "commonPipelineEnvironment")
|
||||
telemetryData.Duration = fmt.Sprintf("%v", time.Since(startTime).Milliseconds())
|
||||
telemetryData.ErrorCategory = log.GetErrorCategory().String()
|
||||
telemetry.Send(&telemetryData)
|
||||
}
|
||||
log.DeferExitHandler(handler)
|
||||
defer handler()
|
||||
telemetry.Initialize(GeneralConfig.NoTelemetry, STEP_NAME)
|
||||
abapEnvironmentAssembleConfirm(stepConfig, &telemetryData, &commonPipelineEnvironment)
|
||||
telemetryData.ErrorCode = "0"
|
||||
log.Entry().Info("SUCCESS")
|
||||
},
|
||||
}
|
||||
|
||||
addAbapEnvironmentAssembleConfirmFlags(createAbapEnvironmentAssembleConfirmCmd, &stepConfig)
|
||||
return createAbapEnvironmentAssembleConfirmCmd
|
||||
}
|
||||
|
||||
func addAbapEnvironmentAssembleConfirmFlags(cmd *cobra.Command, stepConfig *abapEnvironmentAssembleConfirmOptions) {
|
||||
cmd.Flags().StringVar(&stepConfig.CfAPIEndpoint, "cfApiEndpoint", os.Getenv("PIPER_cfApiEndpoint"), "Cloud Foundry API endpoint")
|
||||
cmd.Flags().StringVar(&stepConfig.CfOrg, "cfOrg", os.Getenv("PIPER_cfOrg"), "Cloud Foundry target organization")
|
||||
cmd.Flags().StringVar(&stepConfig.CfSpace, "cfSpace", os.Getenv("PIPER_cfSpace"), "Cloud Foundry target space")
|
||||
cmd.Flags().StringVar(&stepConfig.CfServiceInstance, "cfServiceInstance", os.Getenv("PIPER_cfServiceInstance"), "Cloud Foundry Service Instance")
|
||||
cmd.Flags().StringVar(&stepConfig.CfServiceKeyName, "cfServiceKeyName", os.Getenv("PIPER_cfServiceKeyName"), "Cloud Foundry Service Key")
|
||||
cmd.Flags().StringVar(&stepConfig.Host, "host", os.Getenv("PIPER_host"), "Specifies the host address of the SAP Cloud Platform ABAP Environment system")
|
||||
cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User for either the Cloud Foundry API or the Communication Arrangement for SAP_COM_0582")
|
||||
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.MarkFlagRequired("username")
|
||||
cmd.MarkFlagRequired("password")
|
||||
cmd.MarkFlagRequired("addonDescriptor")
|
||||
cmd.MarkFlagRequired("maxRuntimeInMinutes")
|
||||
}
|
||||
|
||||
// retrieve step metadata
|
||||
func abapEnvironmentAssembleConfirmMetadata() config.StepData {
|
||||
var theMetaData = config.StepData{
|
||||
Metadata: config.StepMetadata{
|
||||
Name: "abapEnvironmentAssembleConfirm",
|
||||
Aliases: []config.Alias{},
|
||||
Description: "Confirm the Delivery of Assembly for installation, support package or patch in SAP Cloud Platform ABAP Environment system",
|
||||
},
|
||||
Spec: config.StepSpec{
|
||||
Inputs: config.StepInputs{
|
||||
Parameters: []config.StepParameters{
|
||||
{
|
||||
Name: "cfApiEndpoint",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "cloudFoundry/apiEndpoint"}},
|
||||
},
|
||||
{
|
||||
Name: "cfOrg",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "cloudFoundry/org"}},
|
||||
},
|
||||
{
|
||||
Name: "cfSpace",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "cloudFoundry/space"}},
|
||||
},
|
||||
{
|
||||
Name: "cfServiceInstance",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "cloudFoundry/serviceInstance"}},
|
||||
},
|
||||
{
|
||||
Name: "cfServiceKeyName",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "cloudFoundry/serviceKey"}, {Name: "cloudFoundry/serviceKeyName"}, {Name: "cfServiceKey"}},
|
||||
},
|
||||
{
|
||||
Name: "host",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
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", "STAGES", "STEPS"},
|
||||
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: true,
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
{
|
||||
Name: "maxRuntimeInMinutes",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
|
||||
Type: "int",
|
||||
Mandatory: true,
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
},
|
||||
},
|
||||
Containers: []config.Container{
|
||||
{Name: "cf", Image: "ppiper/cf-cli"},
|
||||
},
|
||||
Outputs: config.StepOutputs{
|
||||
Resources: []config.StepResources{
|
||||
{
|
||||
Name: "commonPipelineEnvironment",
|
||||
Type: "piperEnvironment",
|
||||
Parameters: []map[string]interface{}{
|
||||
{"Name": "abap/addonDescriptor"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return theMetaData
|
||||
}
|
17
cmd/abapEnvironmentAssembleConfirm_generated_test.go
Normal file
17
cmd/abapEnvironmentAssembleConfirm_generated_test.go
Normal file
@ -0,0 +1,17 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestAbapEnvironmentAssembleConfirmCommand(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCmd := AbapEnvironmentAssembleConfirmCommand()
|
||||
|
||||
// only high level testing performed - details are tested in step generation procedure
|
||||
assert.Equal(t, "abapEnvironmentAssembleConfirm", testCmd.Use, "command name incorrect")
|
||||
|
||||
}
|
72
cmd/abapEnvironmentAssembleConfirm_test.go
Normal file
72
cmd/abapEnvironmentAssembleConfirm_test.go
Normal file
@ -0,0 +1,72 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
abapbuild "github.com/SAP/jenkins-library/pkg/abap/build"
|
||||
"github.com/SAP/jenkins-library/pkg/abaputils"
|
||||
piperhttp "github.com/SAP/jenkins-library/pkg/http"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func testSetupConfirm(client piperhttp.Sender, buildID string) abapbuild.Build {
|
||||
conn := new(abapbuild.Connector)
|
||||
conn.Client = client
|
||||
conn.DownloadClient = &abapbuild.DownloadClientMock{}
|
||||
conn.Header = make(map[string][]string)
|
||||
b := abapbuild.Build{
|
||||
Connector: *conn,
|
||||
BuildID: buildID,
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func TestStartingConfirm(t *testing.T) {
|
||||
t.Run("Run starting", func(t *testing.T) {
|
||||
client := &abapbuild.ClMock{
|
||||
Token: "MyToken",
|
||||
}
|
||||
conn := new(abapbuild.Connector)
|
||||
conn.Client = client
|
||||
conn.Header = make(map[string][]string)
|
||||
var repos []abaputils.Repository
|
||||
repo := abaputils.Repository{
|
||||
Name: "RepoA",
|
||||
Version: "0001",
|
||||
PackageName: "Package",
|
||||
PackageType: "AOI",
|
||||
SpLevel: "0000",
|
||||
PatchLevel: "0000",
|
||||
Status: "P",
|
||||
Namespace: "/DEMO/",
|
||||
}
|
||||
repos = append(repos, repo)
|
||||
repo.Status = "R"
|
||||
repos = append(repos, repo)
|
||||
|
||||
builds, err := startingConfirm(repos, *conn, time.Duration(0*time.Second))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, len(builds))
|
||||
assert.Equal(t, abapbuild.Accepted, builds[0].build.RunState)
|
||||
})
|
||||
}
|
||||
|
||||
func TestStartingConfirmInvalidInput(t *testing.T) {
|
||||
t.Run("Run starting", func(t *testing.T) {
|
||||
client := &abapbuild.ClMock{
|
||||
Token: "MyToken",
|
||||
}
|
||||
conn := new(abapbuild.Connector)
|
||||
conn.Client = client
|
||||
conn.Header = make(map[string][]string)
|
||||
var repos []abaputils.Repository
|
||||
repo := abaputils.Repository{
|
||||
Name: "RepoA",
|
||||
Status: "P",
|
||||
}
|
||||
repos = append(repos, repo)
|
||||
_, err := startingConfirm(repos, *conn, time.Duration(0*time.Second))
|
||||
assert.Error(t, err)
|
||||
})
|
||||
}
|
@ -14,6 +14,7 @@ func GetAllStepMetadata() map[string]config.StepData {
|
||||
"abapAddonAssemblyKitRegisterPackages": abapAddonAssemblyKitRegisterPackagesMetadata(),
|
||||
"abapAddonAssemblyKitReleasePackages": abapAddonAssemblyKitReleasePackagesMetadata(),
|
||||
"abapAddonAssemblyKitReserveNextPackages": abapAddonAssemblyKitReserveNextPackagesMetadata(),
|
||||
"abapEnvironmentAssembleConfirm": abapEnvironmentAssembleConfirmMetadata(),
|
||||
"abapEnvironmentAssemblePackages": abapEnvironmentAssemblePackagesMetadata(),
|
||||
"abapEnvironmentCheckoutBranch": abapEnvironmentCheckoutBranchMetadata(),
|
||||
"abapEnvironmentCloneGitRepo": abapEnvironmentCloneGitRepoMetadata(),
|
||||
|
@ -125,6 +125,7 @@ func Execute() {
|
||||
rootCmd.AddCommand(IntegrationArtifactDeployCommand())
|
||||
rootCmd.AddCommand(IntegrationArtifactUpdateConfigurationCommand())
|
||||
rootCmd.AddCommand(IntegrationArtifactGetMplStatusCommand())
|
||||
rootCmd.AddCommand(AbapEnvironmentAssembleConfirmCommand())
|
||||
|
||||
addRootFlags(rootCmd)
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
|
111
documentation/docs/steps/abapEnvironmentAssembleConfirm.md
Normal file
111
documentation/docs/steps/abapEnvironmentAssembleConfirm.md
Normal file
@ -0,0 +1,111 @@
|
||||
# ${docGenStepName}
|
||||
|
||||
## ${docGenDescription}
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* A SAP Cloud Platform ABAP Environment system is available.
|
||||
* This can be created manually on cloud foundry.
|
||||
* In a pipeline, you can do this, for example, with the step [cloudFoundryCreateService](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateService/).
|
||||
* Communication Scenario [“SAP Cloud Platform ABAP Environment - Software Assembly Integration (SAP_COM_0582)“](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/26b8df5435c649aa8ea7b3688ad5bb0a.html) is setup for this system.
|
||||
* E.g. a [Communication User](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/0377adea0401467f939827242c1f4014.html), a [Communication System](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/1bfe32ae08074b7186e375ab425fb114.html) and a [Communication Arrangement](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/a0771f6765f54e1c8193ad8582a32edb.html) are configured.
|
||||
* This can be done manually through the respective applications on the SAP Cloud Platform ABAP Environment System,
|
||||
* or through creating a service key for the system on cloud foundry with the parameters {“scenario_id”: “SAP_COM_0582", “type”: “basic”}.
|
||||
* In a pipeline, you can do this, for example, with the step [cloudFoundryCreateServiceKey](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/).
|
||||
* You have following options to provide the ABAP endpoint configuration:
|
||||
* The host and credentials the Cloud Platform ABAP Environment system itself. The credentials must be configured for the Communication Scenario SAP_COM_0582.
|
||||
* The Cloud Foundry parameters (API endpoint, organization, space), credentials, the service instance for the ABAP service and the service key for the Communication Scenario SAP_COM_0582.
|
||||
* Only provide one of those options with the respective credentials. If all values are provided, the direct communication (via host) has priority.
|
||||
* The step needs information about the packages which should be assembled present in the CommonPipelineEnvironment.
|
||||
* For each repository/component version it needs the name of the repository, the version, splevel, patchlevel, namespace, packagename, package type, the status of the package, and optional the predecessor commit id.
|
||||
* To upload this information to the CommonPipelineEnvironment run prior to this step the steps:
|
||||
* [abapAddonAssemblyKitCheckCVs](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitCheckCVs/),
|
||||
* [abapAddonAssemblyKitReserveNextPackages](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitCheckPV/).
|
||||
* If one of the package is already in status released, the assembly for this package will not be executed.
|
||||
* The Software Components for which packages are to be assembled need to be present in the system.
|
||||
* This can be done manually through the respective applications on the SAP Cloud Platform ABAP Environment System.
|
||||
* In a pipeline, you can do this, for example, with the step [abapEnvironmentPullGitRepo](https://sap.github.io/jenkins-library/steps/abapEnvironmentPullGitRepo/).
|
||||
* The packages to be assembled need to be reserved in AAKaaS and the corresponding information needs to be present in CommonPipelineEnvironment. To do so run step [abapAddonAssemblyKitReserveNextPackages](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitReserveNextPackages/) prior this step.
|
||||
|
||||
## ${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
|
||||
abapEnvironmentAssembleConfirm script: this
|
||||
```
|
||||
|
||||
If you want to provide the host and credentials of the Communication Arrangement directly, the configuration could look as follows:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
abapEnvironmentAssembleConfirm:
|
||||
abapCredentialsId: 'abapCredentialsId',
|
||||
host: 'https://myABAPendpoint.com',
|
||||
```
|
||||
|
||||
Or by authenticating against Cloud Foundry and reading the Service Key details from there:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
abapEnvironmentAssembleConfirm:
|
||||
abapCredentialsId: 'cfCredentialsId',
|
||||
cfApiEndpoint : 'https://test.server.com',
|
||||
cfOrg : 'cfOrg',
|
||||
cfSpace: 'cfSpace',
|
||||
cfServiceInstance: 'myServiceInstance',
|
||||
cfServiceKeyName: 'myServiceKey',
|
||||
```
|
||||
|
||||
### Input via the CommonPipelineEnvironment
|
||||
|
||||
```json
|
||||
{"addonProduct":"",
|
||||
"addonVersion":"",
|
||||
"addonVersionAAK":"",
|
||||
"addonUniqueID":"",
|
||||
"customerID":"",
|
||||
"AddonSpsLevel":"",
|
||||
"AddonPatchLevel":"",
|
||||
"TargetVectorID":"",
|
||||
"repositories":[
|
||||
{
|
||||
"name":"/DMO/REPO_A",
|
||||
"tag":"",
|
||||
"branch":"",
|
||||
"version":"",
|
||||
"versionAAK":"0001",
|
||||
"PackageName":"SAPK001001REPOA",
|
||||
"PackageType":"CPK",
|
||||
"SpLevel":"0000",
|
||||
"PatchLevel":"0001",
|
||||
"PredecessorCommitID":"cbb834e9e03cde177d2f109a6676901972983fbc",
|
||||
"Status":"P",
|
||||
"Namespace":"/DMO/",
|
||||
"SarXMLFilePath":""
|
||||
},
|
||||
{
|
||||
"name":"/DMO/REPO_B",
|
||||
"tag":"",
|
||||
"branch":"",
|
||||
"version":"",
|
||||
"versionAAK":"0002",
|
||||
"PackageName":"SAPK002001REPOB",
|
||||
"PackageType":"CPK",
|
||||
"SpLevel":"0001",
|
||||
"PatchLevel":"0001",
|
||||
"PredecessorCommitID":"2f7d43923c041a07a76c8adc859c737ad772ef26",
|
||||
"Status":"P",
|
||||
"Namespace":"/DMO/",
|
||||
"SarXMLFilePath":""
|
||||
}
|
||||
]}
|
||||
```
|
@ -57,6 +57,7 @@ nav:
|
||||
- abapAddonAssemblyKitReleasePackages: steps/abapAddonAssemblyKitReleasePackages.md
|
||||
- abapAddonAssemblyKitReserveNextPackages: steps/abapAddonAssemblyKitReserveNextPackages.md
|
||||
- abapEnvironmentAssemblePackages: steps/abapEnvironmentAssemblePackages.md
|
||||
- abapEnvironmentAssembleConfirm: steps/abapEnvironmentAssembleConfirm.md
|
||||
- abapEnvironmentCheckoutBranch: steps/abapEnvironmentCheckoutBranch.md
|
||||
- abapEnvironmentCloneGitRepo: steps/abapEnvironmentCloneGitRepo.md
|
||||
- abapEnvironmentCreateSystem: steps/abapEnvironmentCreateSystem.md
|
||||
|
127
resources/metadata/abapEnvironmentAssembleConfirm.yaml
Normal file
127
resources/metadata/abapEnvironmentAssembleConfirm.yaml
Normal file
@ -0,0 +1,127 @@
|
||||
metadata:
|
||||
name: abapEnvironmentAssembleConfirm
|
||||
description: "Confirm the Delivery of Assembly for installation, support package or patch in SAP Cloud Platform ABAP Environment system"
|
||||
longDescription: |
|
||||
This step confirms the assemblies of provided [installations, support packages or patches] in SAP Cloud Platform ABAP Environment system
|
||||
spec:
|
||||
inputs:
|
||||
secrets:
|
||||
- name: abapCredentialsId
|
||||
description: Jenkins credentials ID containing user and password to authenticate to the Cloud Platform ABAP Environment system or the Cloud Foundry API
|
||||
type: jenkins
|
||||
aliases:
|
||||
- name: cfCredentialsId
|
||||
- name: credentialsId
|
||||
params:
|
||||
- name: cfApiEndpoint
|
||||
type: string
|
||||
description: Cloud Foundry API endpoint
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- GENERAL
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: cloudFoundry/apiEndpoint
|
||||
- name: cfOrg
|
||||
type: string
|
||||
description: Cloud Foundry target organization
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- GENERAL
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: cloudFoundry/org
|
||||
- name: cfSpace
|
||||
type: string
|
||||
description: Cloud Foundry target space
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- GENERAL
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: cloudFoundry/space
|
||||
- name: cfServiceInstance
|
||||
type: string
|
||||
description: Cloud Foundry Service Instance
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- GENERAL
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: cloudFoundry/serviceInstance
|
||||
- name: cfServiceKeyName
|
||||
type: string
|
||||
description: Cloud Foundry Service Key
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- GENERAL
|
||||
mandatory: false
|
||||
aliases:
|
||||
- name: cloudFoundry/serviceKey
|
||||
- name: cloudFoundry/serviceKeyName
|
||||
- name: cfServiceKey
|
||||
- name: host
|
||||
description: Specifies the host address of the SAP Cloud Platform ABAP Environment system
|
||||
type: string
|
||||
mandatory: false
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- name: username
|
||||
type: string
|
||||
description: User for either the Cloud Foundry API or the Communication Arrangement for SAP_COM_0582
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
mandatory: true
|
||||
secret: true
|
||||
- name: password
|
||||
type: string
|
||||
description: Password for either the Cloud Foundry API or the Communication Arrangement for SAP_COM_0582
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
mandatory: true
|
||||
secret: true
|
||||
- name: addonDescriptor
|
||||
type: string
|
||||
description: Structure in the commonPipelineEnvironment containing information about the Product Version and corresponding Software Component Versions
|
||||
mandatory: true
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
resourceRef:
|
||||
- name: commonPipelineEnvironment
|
||||
param: abap/addonDescriptor
|
||||
- name: maxRuntimeInMinutes
|
||||
type: int
|
||||
description: maximal runtime of the step
|
||||
mandatory: true
|
||||
default: 360
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
outputs:
|
||||
resources:
|
||||
- name: commonPipelineEnvironment
|
||||
type: piperEnvironment
|
||||
params:
|
||||
- name: abap/addonDescriptor
|
||||
containers:
|
||||
- name: cf
|
||||
image: ppiper/cf-cli
|
@ -114,6 +114,7 @@ public class CommonStepsTest extends BasePiperTest{
|
||||
'abapAddonAssemblyKitReleasePackages', //implementing new golang pattern without fields
|
||||
'abapAddonAssemblyKitReserveNextPackages', //implementing new golang pattern without fields
|
||||
'abapEnvironmentAssemblePackages', //implementing new golang pattern without fields
|
||||
'abapEnvironmentAssembleConfirm', //implementing new golang pattern without fields
|
||||
'abapEnvironmentCheckoutBranch', //implementing new golang pattern without fields
|
||||
'abapEnvironmentCloneGitRepo', //implementing new golang pattern without fields
|
||||
'abapEnvironmentPullGitRepo', //implementing new golang pattern without fields
|
||||
|
11
vars/abapEnvironmentAssembleConfirm.groovy
Normal file
11
vars/abapEnvironmentAssembleConfirm.groovy
Normal file
@ -0,0 +1,11 @@
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field String METADATA_FILE = 'metadata/abapEnvironmentAssembleConfirm.yaml'
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
List credentials = [
|
||||
[type: 'usernamePassword', id: 'abapCredentialsId', env: ['PIPER_username', 'PIPER_password']]
|
||||
]
|
||||
piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials, false, false, true)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user