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());
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();
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();
assertThat(logs.getAllAsString()).contains("Project key: com.foo.project");
assertThat(logs.getAllAsString()).doesNotContain("Organization key");
+ assertThat(logs.getAllAsString()).doesNotContain("Branch key");
}
@Test