]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11853 Improve logs about autoconfiguration in CIs
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Mon, 9 Mar 2020 19:53:05 +0000 (14:53 -0500)
committersonartech <sonartech@sonarsource.com>
Fri, 13 Mar 2020 20:04:14 +0000 (20:04 +0000)
sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/CiConfigurationProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/ci/vendors/Jenkins.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java

index 80a557760d5df92cc225d12f54f65d2897b0ed4e..ff7e0cf3bbe367789a1d9c0c4a077addeb595425 100644 (file)
@@ -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();
index d79cbd7c17cdee8b64fc7a15c7e07ce6ea524631..81c0b57931108419b0bc1b5b0a5ed2c2e9cfd101 100644 (file)
@@ -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;
   }
index 13928c69b0f815bed87a2c6d8b40761eb86c5def..76b6d52c589277e685a4fae3cbce328e7b41b713 100644 (file)
@@ -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());
     }
index 0cc41665dea6b1a75bd2b8c178ddf70e300c954a..7850e6ed104b92a1fca6b1fc135e230a7ce5ccdf 100644 (file)
@@ -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'");
   }