Skip to content
Permalink
Browse files

Implemented JENKINS-30386

  • Loading branch information...
MadsNielsen committed Sep 3, 2015
1 parent f116c87 commit fe973698ce655fc8f8ee3b36a899db31810223e4
@@ -77,7 +77,9 @@ public CodeSonarPublisher(List<Condition> conditions, String hubAddress, String
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
String expandedHubAddress = build.getEnvironment(listener).expand(Util.fixNull(hubAddress));
String expandedProjectName = build.getEnvironment(listener).expand(Util.fixNull(projectName));


httpService.setListener(listener);

if (expandedHubAddress.isEmpty()) {
throw new AbortException("Hub address not provided");
}
@@ -91,7 +93,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
if (analysisUrl == null) {
analysisUrl = analysisService.getLatestAnalysisUrlForAProject(expandedHubAddress, expandedProjectName);
}

Analysis analysisActiveWarnings = analysisService.getAnalysisFromUrl(analysisUrl, UrlFilters.ACTIVE);

String metricsUrl = metricsService.getMetricsUrlFromAnAnalysisId(expandedHubAddress, analysisActiveWarnings.getAnalysisId());
@@ -1,7 +1,7 @@
package org.jenkinsci.plugins.codesonar.services;

import hudson.AbortException;
import java.io.IOException;
import hudson.model.BuildListener;
import java.io.Serializable;
import org.apache.http.client.fluent.Request;

@@ -10,15 +10,30 @@
* @author Andrius
*/
public class HttpService implements Serializable {
private transient BuildListener listener;

public String getContentFromUrlAsString(String url) throws AbortException {
log(String.format("Request sent to %s", url));

String output;
try {
output = Request.Get(url).execute().returnContent().asString();
} catch (Exception e) {
log(String.format("Error on url: %s", url));
log(String.format("Exception message is: %s", e.getMessage()));
throw new AbortException(e.getMessage());
}

return output;
}

public void setListener(BuildListener listener) {
this.listener = listener;
}

private void log(String content) {
if(listener != null) {
listener.getLogger().println("[CodeSonar] "+content);
}
}
}

0 comments on commit fe97369

Please sign in to comment.
You can’t perform that action at this time.