Commit e42ba831 authored by Tim Olshansky's avatar Tim Olshansky

Merge pull request #120 from rockwotj/master

Added getBuildsArtifact method
parents 68489e45 8d160022
......@@ -612,6 +612,29 @@ public class GitlabAPI {
}
/**
* Get build artifacts of a project build
*
* @param project The Project
* @param build The build
* @throws IOException on gitlab api call error
*/
public byte[] getBuildArtifact(GitlabProject project, GitlabBuild build) throws IOException {
return getBuildArtifact(project.getId(), build.getId());
}
/**
* Get build artifacts of a project build
*
* @param projectId The Project's Id
* @param buildId The build's Id
* @throws IOException on gitlab api call error
*/
public byte[] getBuildArtifact(Integer projectId, Integer buildId) throws IOException {
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabBuild.URL + "/" + buildId + "/artifacts";
return retrieve().to(tailUrl, byte[].class);
}
/**
* Creates a private Project
*
......
......@@ -321,10 +321,10 @@ public class GitlabHTTPRequestor {
private <T> T parse(HttpURLConnection connection, Class<T> type, T instance) throws IOException {
InputStreamReader reader = null;
try {
reader = new InputStreamReader(wrapStream(connection, connection.getInputStream()), "UTF-8");
if (byte[].class == type) {
return type.cast(IOUtils.toByteArray(reader));
return type.cast(IOUtils.toByteArray(wrapStream(connection, connection.getInputStream())));
}
reader = new InputStreamReader(wrapStream(connection, connection.getInputStream()), "UTF-8");
String data = IOUtils.toString(reader);
if (type != null) {
return GitlabAPI.MAPPER.readValue(data, type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment