diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2016-03-16 09:33:56 +0100 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2016-03-16 09:54:13 +0100 |
commit | f29df5da27030596d7d3ef07b4e833bb664cb940 (patch) | |
tree | e073c4cab615853eab8b6a3c92dc06abb926a2c3 /sonar-batch/src/main/java/org | |
parent | 812bbbf8aee19bab8e9cc7d93d450dc5f31e991c (diff) | |
download | sonarqube-f29df5da27030596d7d3ef07b4e833bb664cb940.tar.gz sonarqube-f29df5da27030596d7d3ef07b4e833bb664cb940.zip |
SONAR-7235 Improve error message when server public URL is not a valid URL
Diffstat (limited to 'sonar-batch/src/main/java/org')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java index 47e92a283d6..c62ccd63c56 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java +++ b/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java @@ -90,6 +90,13 @@ public class ReportPublisher implements Startable { 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 @@ -172,23 +179,21 @@ public class ReportPublisher implements Startable { 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() |