Commit 41232852 authored by rockwotj's avatar rockwotj

Added builds API for projects and commits

parent 13259f51
...@@ -586,6 +586,32 @@ public class GitlabAPI { ...@@ -586,6 +586,32 @@ public class GitlabAPI {
return retrieve().getAll(tailUrl, GitlabProject[].class); return retrieve().getAll(tailUrl, GitlabProject[].class);
} }
/**
*
* Gets a list of a project's builds in Gitlab
*
* @param project the project
* @return A list of project builds
* @throws IOException
*/
public List<GitlabBuild> getProjectBuilds(GitlabProject project) throws IOException {
return getProjectBuilds(project.getId());
}
/**
*
* Gets a list of a project's builds in Gitlab
*
* @param projectId the project id
* @return A list of project builds
* @throws IOException
*/
public List<GitlabBuild> getProjectBuilds(Integer projectId) throws IOException {
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabBuild.URL;
return retrieve().getAll(tailUrl, GitlabBuild[].class);
}
/** /**
* Creates a private Project * Creates a private Project
* *
...@@ -875,6 +901,17 @@ public class GitlabAPI { ...@@ -875,6 +901,17 @@ public class GitlabAPI {
return retrieve().to(tailUrl, GitlabCommit.class); return retrieve().to(tailUrl, GitlabCommit.class);
} }
public List<GitlabBuild> getCommitBuilds(GitlabProject projectId, String commitHash) throws IOException {
return getCommitBuilds(projectId.getId(), commitHash);
}
public List<GitlabBuild> getCommitBuilds(Serializable projectId, String commitHash) throws IOException {
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + "/repository/commits/" + commitHash + GitlabBuild.URL;
return retrieve().getAll(tailUrl, GitlabBuild[].class);
}
public List<GitlabCommit> getCommits(GitlabMergeRequest mergeRequest) throws IOException { public List<GitlabCommit> getCommits(GitlabMergeRequest mergeRequest) throws IOException {
return getCommits(mergeRequest, new Pagination()); return getCommits(mergeRequest, new Pagination());
} }
......
package org.gitlab.api.models;
import com.fasterxml.jackson.annotation.JsonProperty;
public class GitlabBuild {
public final static String URL = "/builds";
private GitlabCommit commit;
private String coverage;
@JsonProperty("created_at")
private String createdAt;
@JsonProperty("download_url")
private String downloadUrl;
@JsonProperty("finishedAt")
private String finishedAt;
private Integer id;
private String name;
private String ref;
private GitlabRunner runner;
private String stage;
@JsonProperty("started_at")
private String startedAt;
private String status;
private Boolean tag;
private GitlabUser user;
public GitlabUser getUser() {
return user;
}
public void setUser(GitlabUser user) {
this.user = user;
}
public Boolean getTag() {
return tag;
}
public void setTag(Boolean tag) {
this.tag = tag;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getStartedAt() {
return startedAt;
}
public void setStartedAt(String startedAt) {
this.startedAt = startedAt;
}
public String getStage() {
return stage;
}
public void setStage(String stage) {
this.stage = stage;
}
public GitlabRunner getRunner() {
return runner;
}
public void setRunner(GitlabRunner runner) {
this.runner = runner;
}
public String getRef() {
return ref;
}
public void setRef(String ref) {
this.ref = ref;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getFinishedAt() {
return finishedAt;
}
public void setFinishedAt(String finishedAt) {
this.finishedAt = finishedAt;
}
public String getDownloadUrl() {
return downloadUrl;
}
public void setDownloadUrl(String downloadUrl) {
this.downloadUrl = downloadUrl;
}
public String getCreatedAt() {
return createdAt;
}
public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}
public String getCoverage() {
return coverage;
}
public void setCoverage(String coverage) {
this.coverage = coverage;
}
public GitlabCommit getCommit() {
return commit;
}
public void setCommit(GitlabCommit commit) {
this.commit = commit;
}
}
package org.gitlab.api.models;
import com.fasterxml.jackson.annotation.JsonProperty;
public class GitlabRunner {
private Integer id;
private String description;
private Boolean active;
@JsonProperty("is_shared")
private Boolean isShared;
private String name;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
}
public Boolean getShared() {
return isShared;
}
public void setShared(Boolean shared) {
isShared = shared;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
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