1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

Revert adding JaCoCo report paths to options (#2017)

This commit is contained in:
Stephan Aßmus 2020-09-14 17:40:02 +02:00 committed by GitHub
parent eef3bcde60
commit 6a0d694d0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 43 deletions

View File

@ -54,7 +54,6 @@ const (
javaLibraries = "sonar.java.libraries="
coverageExclusions = "sonar.coverage.exclusions="
pomXMLPattern = "**/pom.xml"
jacocoReportPattern = "**/target/**/jacoco.xml"
)
func sonarExecuteScan(config sonarExecuteScanOptions, _ *telemetry.CustomData, influx *sonarExecuteScanInflux) {
@ -112,9 +111,6 @@ func runSonar(config sonarExecuteScanOptions, client piperhttp.Downloader, runne
if config.InferJavaBinaries && !isInOptions(config, javaBinaries) {
addJavaBinaries()
}
if !isInOptions(config, coverageReportPaths) {
addJacocoReportPaths()
}
if err := handlePullRequest(config); err != nil {
log.SetErrorCategory(log.ErrorConfiguration)
return err
@ -168,17 +164,6 @@ func isInOptions(config sonarExecuteScanOptions, property string) bool {
return SliceUtils.ContainsStringPart(config.Options, property)
}
func addJacocoReportPaths() {
matches, err := doublestarGlob(jacocoReportPattern)
if err != nil {
log.Entry().Warnf("failed to glob for Jacoco report paths: %v", err)
return
}
if len(matches) > 0 {
sonar.addOption(coverageReportPaths + strings.Join(matches, ","))
}
}
func addJavaBinaries() {
pomFiles, err := doublestarGlob(pomXMLPattern)
if err != nil {

View File

@ -163,34 +163,6 @@ func TestRunSonar(t *testing.T) {
assert.NoError(t, err)
assert.Contains(t, sonar.options, "-Dsonar.projectKey=piper")
})
t.Run("with jacoco reports", func(t *testing.T) {
// init
tmpFolder, err := ioutil.TempDir(".", "test-sonar-")
require.NoError(t, err)
defer func() { _ = os.RemoveAll(tmpFolder) }()
createTaskReportFile(t, tmpFolder)
sonar = sonarSettings{
workingDir: tmpFolder,
binary: "sonar-scanner",
environment: []string{},
options: []string{},
}
fileUtilsExists = mockFileUtilsExists(true)
globMatches := make(map[string][]string)
globMatches[jacocoReportPattern] = []string{"target/site/jacoco.xml", "application/target/site/jacoco.xml"}
doublestarGlob = mockGlob(globMatches)
defer func() {
fileUtilsExists = FileUtils.FileExists
doublestarGlob = doublestar.Glob
}()
options := sonarExecuteScanOptions{}
// test
err = runSonar(options, &mockClient, &mockRunner)
// assert
assert.NoError(t, err)
assert.Contains(t, sonar.options, "-Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco.xml,application/target/site/jacoco.xml")
})
t.Run("with binaries option", func(t *testing.T) {
// init
tmpFolder, err := ioutil.TempDir(".", "test-sonar-")