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:
parent
eef3bcde60
commit
6a0d694d0c
@ -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 {
|
||||
|
@ -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-")
|
||||
|
Loading…
Reference in New Issue
Block a user