1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-09-16 09:26:22 +02:00

Merge branch 'master' into python311

This commit is contained in:
Christopher Fenner
2025-09-05 12:26:48 +02:00
committed by GitHub
5 changed files with 42 additions and 7 deletions

View File

@@ -86,7 +86,7 @@ func runAssemblePackages(config *abapEnvironmentAssemblePackagesOptions, com aba
return nil, errConBuild
}
builds, err := executeBuilds(addonDescriptor, *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, config.AlternativePhaseName)
if err != nil {
return builds, errors.Wrap(err, "Starting Builds for Repositories with reserved AAKaaS packages failed")
}
@@ -111,7 +111,7 @@ func runAssemblePackages(config *abapEnvironmentAssemblePackagesOptions, com aba
return builds, nil
}
func executeBuilds(addonDescriptor *abaputils.AddonDescriptor, 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, altenativePhaseName string) ([]buildWithRepository, error) {
var builds []buildWithRepository
for _, repo := range addonDescriptor.Repositories {
@@ -125,7 +125,7 @@ func executeBuilds(addonDescriptor *abaputils.AddonDescriptor, conn abapbuild.Co
if repo.Status == "P" {
buildRepo.repo.InBuildScope = true
err := buildRepo.start(addonDescriptor)
err := buildRepo.start(addonDescriptor, altenativePhaseName)
if err != nil {
buildRepo.build.RunState = abapbuild.Failed
buildRepo.repo.ErrorText = fmt.Sprint(err)
@@ -169,7 +169,7 @@ func (br *buildWithRepository) waitToBeFinished(maxRuntimeInMinutes time.Duratio
}
}
func (br *buildWithRepository) start(addonDescriptor *abaputils.AddonDescriptor) error {
func (br *buildWithRepository) start(addonDescriptor *abaputils.AddonDescriptor, altenativePhaseName string) 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")
}
@@ -234,8 +234,15 @@ func (br *buildWithRepository) start(addonDescriptor *abaputils.AddonDescriptor)
abapbuild.Value{ValueID: "ADDITIONAL_PIECELIST",
Value: br.repo.AdditionalPiecelist})
}
phase := "BUILD_" + br.repo.PackageType
log.Entry().Infof("Starting assembly of package %s", br.repo.PackageName)
var phase string
if altenativePhaseName != "" {
phase = altenativePhaseName
} else {
phase = "BUILD_" + br.repo.PackageType
}
log.Entry().Infof("Starting assembly of package %s as %s", br.repo.PackageName, phase)
return br.build.Start(phase, valuesInput)
}

View File

@@ -31,6 +31,7 @@ type abapEnvironmentAssemblePackagesOptions struct {
MaxRuntimeInMinutes int `json:"maxRuntimeInMinutes,omitempty"`
PollIntervalsInMilliseconds int `json:"pollIntervalsInMilliseconds,omitempty"`
CertificateNames []string `json:"certificateNames,omitempty"`
AlternativePhaseName string `json:"alternativePhaseName,omitempty"`
}
type abapEnvironmentAssemblePackagesCommonPipelineEnvironment struct {
@@ -213,6 +214,7 @@ func addAbapEnvironmentAssemblePackagesFlags(cmd *cobra.Command, stepConfig *aba
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{}, "file names of trusted (self-signed) server certificates - need to be stored in .pipeline/trustStore")
cmd.Flags().StringVar(&stepConfig.AlternativePhaseName, "alternativePhaseName", os.Getenv("PIPER_alternativePhaseName"), "overrides default phase name")
cmd.MarkFlagRequired("username")
cmd.MarkFlagRequired("password")
@@ -348,6 +350,15 @@ func abapEnvironmentAssemblePackagesMetadata() config.StepData {
Aliases: []config.Alias{},
Default: []string{},
},
{
Name: "alternativePhaseName",
ResourceRef: []config.ResourceReference{},
Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"},
Type: "string",
Mandatory: false,
Aliases: []config.Alias{},
Default: os.Getenv("PIPER_alternativePhaseName"),
},
},
},
Containers: []config.Container{

View File

@@ -72,7 +72,7 @@ func TestStartingInvalidInput(t *testing.T) {
},
},
}
builds, err := executeBuilds(&aD, *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)

View File

@@ -2,6 +2,7 @@ package npm
import (
"fmt"
"os"
"path/filepath"
"github.com/SAP/jenkins-library/pkg/log"
@@ -52,6 +53,13 @@ func (pm *PackageManager) InstallPnpm(execRunner ExecRunner, pnpmVersion string,
if err := execRunner.RunExecutable("npm", "install", pnpmPackage, "--prefix", prefixPath); err != nil {
return fmt.Errorf("failed to install pnpm locally: %w", err)
}
// Add the local pnpm bin directory to PATH so it's globally available
pnpmBinDir := filepath.Join(prefixPath, "node_modules", ".bin")
currentPath := os.Getenv("PATH")
newPath := pnpmBinDir + string(os.PathListSeparator) + currentPath
os.Setenv("PATH", newPath)
return nil
}

View File

@@ -140,6 +140,15 @@ spec:
- STAGES
- STEPS
- GENERAL
- name: alternativePhaseName
description: overrides default phase name
type: string
mandatory: false
scope:
- PARAMETERS
- STAGES
- STEPS
- GENERAL
outputs:
resources:
- name: commonPipelineEnvironment