reportDir = new File(projectReactor.getRoot().getWorkDir(), "batch-report");
writer = new BatchReportWriter(reportDir);
contextPublisher.init(writer);
+
+ if (!analysisMode.isIssues() && !analysisMode.isMediumTest()) {
+ String publicUrl = publicUrl();
+ if (HttpUrl.parse(publicUrl) == null) {
+ throw MessageException.of("Failed to parse public URL set in SonarQube server: " + publicUrl);
+ }
+ }
}
@Override
if (taskId == null) {
LOG.info("ANALYSIS SUCCESSFUL");
} else {
+ String publicUrl = publicUrl();
+ HttpUrl httpUrl = HttpUrl.parse(publicUrl);
+
Map<String, String> metadata = new LinkedHashMap<>();
String effectiveKey = projectReactor.getRoot().getKeyWithBranch();
metadata.put("projectKey", effectiveKey);
- metadata.put("serverUrl", publicUrl());
-
- HttpUrl publicUrl = HttpUrl.parse(publicUrl());
- if (publicUrl == null) {
- throw MessageException.of("Failed to parse public URL set in SonarQube server: " + publicUrl());
- }
+ metadata.put("serverUrl", publicUrl);
- URL dashboardUrl = publicUrl.newBuilder()
+ URL dashboardUrl = httpUrl.newBuilder()
.addPathSegment("dashboard").addPathSegment("index").addPathSegment(effectiveKey)
.build()
.url();
metadata.put("dashboardUrl", dashboardUrl.toExternalForm());
- URL taskUrl = HttpUrl.parse(publicUrl()).newBuilder()
+ URL taskUrl = HttpUrl.parse(publicUrl).newBuilder()
.addPathSegment("api").addPathSegment("ce").addPathSegment("task")
.addQueryParameter("id", taskId)
.build()
public void fail_if_public_url_malformed() throws IOException {
settings.setProperty(CoreProperties.SERVER_BASE_URL, "invalid");
ReportPublisher underTest = new ReportPublisher(settings, wsClient, contextPublisher, reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
-
+
exception.expect(MessageException.class);
exception.expectMessage("Failed to parse public URL set in SonarQube server: invalid");
- underTest.logSuccess("TASK-123");
+ underTest.start();
}
@Test