From: Duarte Meneses Date: Mon, 9 Mar 2020 19:53:05 +0000 (-0500) Subject: SONAR-11853 Improve logs about autoconfiguration in CIs X-Git-Tag: 8.3.0.34182~138 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=27a35cf5aa760828047510cd329e6a49fa4f102a;p=sonarqube.git SONAR-11853 Improve logs about autoconfiguration in CIs --- diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/CiConfigurationProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/CiConfigurationProvider.java index 80a557760d5..ff7e0cf3bbe 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/CiConfigurationProvider.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/CiConfigurationProvider.java @@ -51,7 +51,7 @@ public class CiConfigurationProvider extends ProviderAdapter { if (detectedVendors.size() == 1) { CiVendor vendor = detectedVendors.get(0); - LOG.info("Detected {}", vendor.getName()); + LOG.info("Auto-configuring with CI '{}'", vendor.getName()); return vendor.loadConfiguration(); } return new EmptyCiConfiguration(); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/vendors/Jenkins.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/vendors/Jenkins.java index d79cbd7c17c..81c0b579311 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/vendors/Jenkins.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/vendors/Jenkins.java @@ -35,7 +35,7 @@ import org.sonar.scanner.ci.CiVendor; import static org.apache.commons.lang.StringUtils.isNotBlank; public class Jenkins implements CiVendor { - private final static Logger log = Loggers.get(Jenkins.class); + private static final Logger LOG = Loggers.get(Jenkins.class); private final System2 system; private final DefaultInputProject inputProject; @@ -104,7 +104,7 @@ public class Jenkins implements CiVendor { return ref.getObjectId().getName(); } } catch (Exception e) { - log.debug("Couldn't find git sha1 in '{}': {}", refName, e.getMessage()); + LOG.debug("Couldn't find git sha1 in '{}': {}", refName, e.getMessage()); } return null; } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java index 13928c69b0f..76b6d52c589 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java @@ -146,7 +146,10 @@ public class MetadataPublisher implements ReportPublisherStep { private void addScmInformation(ScannerReport.Metadata.Builder builder) { try { - scmRevision.get().ifPresent(builder::setScmRevisionId); + scmRevision.get().ifPresent(revisionId -> { + LOG.debug("SCM revision ID '{}'", revisionId); + builder.setScmRevisionId(revisionId); + }); } catch (UnsupportedOperationException e) { LOG.debug(e.getMessage()); } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java index 0cc41665dea..7850e6ed104 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java @@ -256,7 +256,7 @@ public class FileSystemMediumTest { .execute(); assertThat(logTester.logs()).contains("1 file indexed"); - assertThat(logTester.logs()).contains("'src" + File.separator + "sample.unknown' indexed with language 'null'"); + assertThat(logTester.logs()).contains("'src" + File.separator + "sample.unknown' indexed with no language"); assertThat(logTester.logs()).contains("'src/sample.unknown' generated metadata with charset 'UTF-8'"); DefaultInputFile inputFile = (DefaultInputFile) result.inputFile("src/sample.unknown"); assertThat(result.getReportComponent(inputFile)).isNotNull(); @@ -289,7 +289,7 @@ public class FileSystemMediumTest { .build()) .execute(); - assertThat(logTester.logs()).containsOnlyOnce("'src" + File.separator + "myfile.binary' indexed with language 'null'"); + assertThat(logTester.logs()).containsOnlyOnce("'src" + File.separator + "myfile.binary' indexed with no language"); assertThat(logTester.logs()).doesNotContain("Evaluate issue exclusions for 'src/myfile.binary'"); assertThat(logTester.logs()).containsOnlyOnce("Evaluate issue exclusions for 'src/sample.xoo'"); }