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

Translate verbose to sonar binary verbose flag (#3567)

* Translate Piper verbose to sonar bin flag

* Add test
This commit is contained in:
Oliver Feldmann 2022-02-24 16:37:07 +01:00 committed by GitHub
parent b599d6f9fa
commit b75db369d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -137,6 +137,9 @@ func runSonar(config sonarExecuteScanOptions, client piperhttp.Downloader, runne
}
sonar.addOption("sonar.projectVersion=" + version)
}
if GeneralConfig.Verbose {
sonar.addOption("sonar.verbose=true")
}
if len(config.ProjectKey) > 0 {
sonar.addOption("sonar.projectKey=" + config.ProjectKey)
}

View File

@ -299,7 +299,7 @@ func TestRunSonar(t *testing.T) {
filepath.Join("target", "classes")))
assert.Contains(t, sonar.options, "-Dsonar.java.binaries=user/provided")
})
t.Run("projectKey, coverageExclusions, m2Path", func(t *testing.T) {
t.Run("projectKey, coverageExclusions, m2Path, verbose", func(t *testing.T) {
// init
tmpFolder, err := ioutil.TempDir(".", "test-sonar-")
require.NoError(t, err)
@ -319,6 +319,8 @@ func TestRunSonar(t *testing.T) {
CoverageExclusions: []string{"one", "**/two", "three**"},
PullRequestProvider: "GitHub",
}
GeneralConfig.Verbose = true
defer func() { GeneralConfig.Verbose = false }()
fileUtilsExists = mockFileUtilsExists(true)
defer func() {
fileUtilsExists = FileUtils.FileExists
@ -331,6 +333,7 @@ func TestRunSonar(t *testing.T) {
assert.Contains(t, sonar.options, fmt.Sprintf("-Dsonar.java.libraries=%s",
filepath.Join("my/custom/m2", "**")))
assert.Contains(t, sonar.options, "-Dsonar.coverage.exclusions=one,**/two,three**")
assert.Contains(t, sonar.options, "-Dsonar.verbose=true")
})
}