github.com/ouraigua/jenkins-library@v0.0.0-20231028010029-fbeaf2f3aa9b/pkg/versioning/descriptorUtils.go (about) 1 package versioning 2 3 import ( 4 "github.com/Masterminds/sprig" 5 6 "github.com/SAP/jenkins-library/pkg/log" 7 "github.com/SAP/jenkins-library/pkg/piperutils" 8 ) 9 10 // DetermineProjectCoordinatesWithCustomVersion resolves the coordinates of the project for use in 3rd party scan tools 11 // It considers a custom version if provided instead of using the GAV version adapted according to the versionScheme 12 func DetermineProjectCoordinatesWithCustomVersion(nameTemplate, versionScheme, customVersion string, gav Coordinates) (string, string) { 13 name, version := DetermineProjectCoordinates(nameTemplate, versionScheme, gav) 14 if len(customVersion) > 0 { 15 log.Entry().Infof("Using custom version: %v", customVersion) 16 return name, customVersion 17 } 18 return name, version 19 } 20 21 // DetermineProjectCoordinates resolves the coordinates of the project for use in 3rd party scan tools 22 func DetermineProjectCoordinates(nameTemplate, versionScheme string, gav Coordinates) (string, string) { 23 projectName, err := piperutils.ExecuteTemplateFunctions(nameTemplate, sprig.HermeticTxtFuncMap(), gav) 24 if err != nil { 25 log.Entry().Warnf("Unable to resolve project name: %v", err) 26 } 27 28 projectVersion := ApplyVersioningModel(versionScheme, gav.Version) 29 return projectName, projectVersion 30 }