1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-30 05:59:39 +02:00

fix(detectExecuteScan) Fixed problem with duplication of maven command (#4412)

* Fixed problem with duplication of maven command

* go fmt
This commit is contained in:
Andrei Kireev 2023-06-23 15:24:03 +03:00 committed by GitHub
parent f81b473723
commit ae4550d0dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 1 deletions

View File

@ -412,7 +412,7 @@ func addDetectArgs(args []string, config detectExecuteScanOptions, utils detectU
mavenArgs = append(mavenArgs, fmt.Sprintf("-Dmaven.repo.local=%v", absolutePath))
}
if len(mavenArgs) > 0 {
if len(mavenArgs) > 0 && !checkIfArgumentIsInScanProperties(config, "detect.maven.build.command") {
args = append(args, fmt.Sprintf("\"--detect.maven.build.command='%v'\"", strings.Join(mavenArgs, " ")))
}

View File

@ -748,6 +748,46 @@ func TestAddDetectArgs(t *testing.T) {
"--detect.output.path='report'",
},
},
{
args: []string{"--testProp1=1"},
options: detectExecuteScanOptions{
ServerURL: "https://server.url",
BuildTool: "maven",
Token: "apiToken",
ProjectName: "Rapid_scan_on_PRs",
Version: "2.0",
VersioningModel: "major-minor",
CodeLocation: "",
ScanPaths: []string{"path1", "path2"},
M2Path: "./m2",
GlobalSettingsFile: "pipeline/settings.xml",
ScanProperties: []string{
"--detect.maven.build.command= --settings .pipeline/settings.xml -DskipTests install",
},
MinScanInterval: 4,
CustomScanVersion: "2.0",
},
isPullRequest: true,
expected: []string{
"--testProp1=1",
"--detect.blackduck.signature.scanner.arguments='--min-scan-interval=4'",
"--detect.maven.build.command=",
"--settings",
".pipeline/settings.xml",
"-DskipTests",
"install",
"--blackduck.url=https://server.url",
"--blackduck.api.token=apiToken",
"\"--detect.project.name='Rapid_scan_on_PRs'\"",
"\"--detect.project.version.name='2.0'\"",
"\"--detect.code.location.name='Rapid_scan_on_PRs/2.0'\"",
"--detect.blackduck.signature.scanner.paths=path1,path2",
"--detect.source.path='.'",
"--detect.blackduck.scan.mode='RAPID'",
"--detect.cleanup=false",
"--detect.output.path='report'",
},
},
}
for k, v := range testData {