diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2017-02-16 17:48:34 +0100 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2017-02-17 14:04:21 +0100 |
commit | 178a5b15ca505e620a836788df7ca70f530c9b34 (patch) | |
tree | 3108da8fa0184504c929220a8fddbb0b2067b0a0 | |
parent | 37677acb471f4e1b0e0e855bfe704a70af6835d9 (diff) | |
download | sonarqube-178a5b15ca505e620a836788df7ca70f530c9b34.tar.gz sonarqube-178a5b15ca505e620a836788df7ca70f530c9b34.zip |
SONAR-8769 Display project and organization keys in the analysis logs
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java | 4 | ||||
-rw-r--r-- | sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java | 25 |
2 files changed, 28 insertions, 1 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java index 7bbb1247828..332a976d76c 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java @@ -238,6 +238,10 @@ public class ProjectScanContainer extends ComponentContainer { if (StringUtils.isNotEmpty(organization)) { LOG.info("Organization key: {}", organization); } + String branch = tree.root().definition().getBranch(); + if (branch != null) { + LOG.info("Branch key: {}", branch); + } LOG.debug("Start recursive analysis of project modules"); scanRecursively(tree, tree.root()); 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 64a3018c6a3..96e8df3f64d 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 @@ -135,6 +135,7 @@ public class FileSystemMediumTest { public void logProjectKeyAndOrganizationKey() throws IOException { builder = createBuilder(); builder.put("sonar.organization", "my org"); + builder.put("sonar.branch", ""); File srcDir = new File(baseDir, "src"); srcDir.mkdir(); @@ -149,8 +150,29 @@ public class FileSystemMediumTest { assertThat(logs.getAllAsString()).contains("Project key: com.foo.project"); assertThat(logs.getAllAsString()).contains("Organization key: my org"); + assertThat(logs.getAllAsString()).doesNotContain("Branch key"); } - + + @Test + public void logBranchKey() throws IOException { + builder = createBuilder(); + builder.put("sonar.branch", "my-branch"); + File srcDir = new File(baseDir, "src"); + srcDir.mkdir(); + + File xooFile = new File(srcDir, "sample.xoo"); + FileUtils.write(xooFile, "Sample xoo\ncontent"); + + tester.newTask() + .properties(builder + .put("sonar.sources", "src") + .build()) + .start(); + + assertThat(logs.getAllAsString()).contains("Project key: com.foo.project"); + assertThat(logs.getAllAsString()).contains("Branch key: my-branch"); + } + @Test public void dontLogInvalidOrganization() throws IOException { builder = createBuilder(); @@ -168,6 +190,7 @@ public class FileSystemMediumTest { assertThat(logs.getAllAsString()).contains("Project key: com.foo.project"); assertThat(logs.getAllAsString()).doesNotContain("Organization key"); + assertThat(logs.getAllAsString()).doesNotContain("Branch key"); } @Test |