Skip to content

Commit c4019cf

Browse files
authored
detectExecuteScan - added parameter for diagnostic mode (#4937)
* detectExecuteScan - added parameter for diagnostic mode * changed-syntax * added-custom-output-path * amended-directory-creation
1 parent ce34dd3 commit c4019cf

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

cmd/detectExecuteScan.go

+15
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,21 @@ func addDetectArgs(args []string, config detectExecuteScanOptions, utils detectU
528528
args = append(args, fmt.Sprintf("--detect.tools=%v", strings.Join(config.DetectTools, ",")))
529529
}
530530

531+
if config.EnableDiagnostics {
532+
args = append(args, fmt.Sprintf("\"--detect.diagnostic=true\""))
533+
args = append(args, fmt.Sprintf("\"--detect.cleanup=false\""))
534+
535+
err := utils.MkdirAll("./blackduckDiagnostics", 0o755)
536+
if err != nil {
537+
return nil, errors.Wrap(err, "failed to create diagnostics directory")
538+
}
539+
540+
log.Entry().Info("Diagnostics enabled, output will be stored in ./blackduckDiagnostics")
541+
542+
args = append(args, fmt.Sprintf("\"--detect.scan.output.path=./blackduckDiagnostics\""))
543+
args = append(args, fmt.Sprintf("\"--detect.output.path=./blackduckDiagnostics\""))
544+
}
545+
531546
// to exclude dependency types for npm
532547
if len(config.NpmDependencyTypesExcluded) > 0 && !checkIfArgumentIsInScanProperties(config, "detect.npm.dependency.types.excluded") {
533548
args = append(args, fmt.Sprintf("--detect.npm.dependency.types.excluded=%v", strings.ToUpper(strings.Join(config.NpmDependencyTypesExcluded, ","))))

cmd/detectExecuteScan_generated.go

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/metadata/detectExecuteScan.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,15 @@ spec:
266266
- STEPS
267267
- STAGES
268268
- PARAMETERS
269+
- name: enableDiagnostics
270+
type: bool
271+
default: false
272+
description:
273+
"Parameter to enable diagnostics file generation by detect script"
274+
scope:
275+
- STEPS
276+
- STAGES
277+
- PARAMETERS
269278
- name: generateReportsForEmptyProjects
270279
type: bool
271280
default: false

0 commit comments

Comments
 (0)