diff --git a/cmd/whitesourceExecuteScan.go b/cmd/whitesourceExecuteScan.go index 1987466d13..14772ec8f6 100644 --- a/cmd/whitesourceExecuteScan.go +++ b/cmd/whitesourceExecuteScan.go @@ -490,6 +490,7 @@ func wsScanOptions(config *ScanOptions) *ws.ScanOptions { AgentDownloadURL: config.AgentDownloadURL, AgentFileName: config.AgentFileName, ConfigFilePath: config.ConfigFilePath, + UseGlobalConfiguration: config.UseGlobalConfiguration, Includes: config.Includes, Excludes: config.Excludes, JreDownloadURL: config.JreDownloadURL, diff --git a/cmd/whitesourceExecuteScan_generated.go b/cmd/whitesourceExecuteScan_generated.go index 30f29a67f5..5456231fe9 100644 --- a/cmd/whitesourceExecuteScan_generated.go +++ b/cmd/whitesourceExecuteScan_generated.go @@ -33,6 +33,7 @@ type whitesourceExecuteScanOptions struct { BuildDescriptorFile string `json:"buildDescriptorFile,omitempty"` BuildTool string `json:"buildTool,omitempty"` ConfigFilePath string `json:"configFilePath,omitempty"` + UseGlobalConfiguration bool `json:"useGlobalConfiguration,omitempty"` ContainerRegistryPassword string `json:"containerRegistryPassword,omitempty"` ContainerRegistryUser string `json:"containerRegistryUser,omitempty"` CreateProductFromPipeline bool `json:"createProductFromPipeline,omitempty"` @@ -352,6 +353,7 @@ func addWhitesourceExecuteScanFlags(cmd *cobra.Command, stepConfig *whitesourceE cmd.Flags().StringVar(&stepConfig.BuildDescriptorFile, "buildDescriptorFile", os.Getenv("PIPER_buildDescriptorFile"), "Explicit path to the build descriptor file.") cmd.Flags().StringVar(&stepConfig.BuildTool, "buildTool", os.Getenv("PIPER_buildTool"), "Defines the tool which is used for building the artifact.") cmd.Flags().StringVar(&stepConfig.ConfigFilePath, "configFilePath", `./wss-unified-agent.config`, "Explicit path to the WhiteSource Unified Agent configuration file.") + cmd.Flags().BoolVar(&stepConfig.UseGlobalConfiguration, "useGlobalConfiguration", false, "The parameter is applicable for multi-module mend projects. If set to true, the configuration file will be used for all modules. Otherwise each module will require its own configuration file in the module folder.") cmd.Flags().StringVar(&stepConfig.ContainerRegistryPassword, "containerRegistryPassword", os.Getenv("PIPER_containerRegistryPassword"), "For `buildTool: docker`: Password for container registry access - typically provided by the CI/CD environment.") cmd.Flags().StringVar(&stepConfig.ContainerRegistryUser, "containerRegistryUser", os.Getenv("PIPER_containerRegistryUser"), "For `buildTool: docker`: Username for container registry access - typically provided by the CI/CD environment.") cmd.Flags().BoolVar(&stepConfig.CreateProductFromPipeline, "createProductFromPipeline", true, "Whether to create the related WhiteSource product on the fly based on the supplied pipeline configuration.") @@ -527,6 +529,15 @@ func whitesourceExecuteScanMetadata() config.StepData { Aliases: []config.Alias{}, Default: `./wss-unified-agent.config`, }, + { + Name: "useGlobalConfiguration", + ResourceRef: []config.ResourceReference{}, + Scope: []string{"PARAMETERS", "GENERAL", "STAGES", "STEPS"}, + Type: "bool", + Mandatory: false, + Aliases: []config.Alias{}, + Default: false, + }, { Name: "containerRegistryPassword", ResourceRef: []config.ResourceReference{ diff --git a/pkg/whitesource/scanOptions.go b/pkg/whitesource/scanOptions.go index 7a3bcb6645..beb6038d9c 100644 --- a/pkg/whitesource/scanOptions.go +++ b/pkg/whitesource/scanOptions.go @@ -31,9 +31,10 @@ type ScanOptions struct { DefaultNpmRegistry string NpmIncludeDevDependencies bool - AgentDownloadURL string - AgentFileName string - ConfigFilePath string + AgentDownloadURL string + AgentFileName string + ConfigFilePath string + UseGlobalConfiguration bool JreDownloadURL string diff --git a/pkg/whitesource/scanUA.go b/pkg/whitesource/scanUA.go index 54e84ddfb3..1e3e3fe01e 100644 --- a/pkg/whitesource/scanUA.go +++ b/pkg/whitesource/scanUA.go @@ -127,6 +127,13 @@ func (s *Scan) ExecuteUAScanInPath(config *ScanOptions, utils Utils, scanPath st } } + if config.UseGlobalConfiguration { + config.ConfigFilePath, err = filepath.Abs(config.ConfigFilePath) + if err != nil { + return err + } + } + configPath, err := config.RewriteUAConfigurationFile(utils, s.AggregateProjectName, config.Verbose) if err != nil { return err diff --git a/resources/metadata/whitesourceExecuteScan.yaml b/resources/metadata/whitesourceExecuteScan.yaml index 95adcdd7fc..9b030ac5b4 100644 --- a/resources/metadata/whitesourceExecuteScan.yaml +++ b/resources/metadata/whitesourceExecuteScan.yaml @@ -128,6 +128,15 @@ spec: - STAGES - STEPS default: ./wss-unified-agent.config + - name: useGlobalConfiguration + type: bool + description: "The parameter is applicable for multi-module mend projects. If set to true, the configuration file will be used for all modules. Otherwise each module will require its own configuration file in the module folder." + scope: + - PARAMETERS + - GENERAL + - STAGES + - STEPS + default: false - name: containerRegistryPassword description: "For `buildTool: docker`: Password for container registry access - typically provided by the CI/CD environment." type: string