Commit 1ee18e9a authored by Greg Messner's avatar Greg Messner
Browse files

Added support for merge request pipeline API calls (#500)

parent becf6896
......@@ -19,6 +19,7 @@ import org.gitlab4j.api.models.MergeRequest;
import org.gitlab4j.api.models.MergeRequestFilter;
import org.gitlab4j.api.models.MergeRequestParams;
import org.gitlab4j.api.models.Participant;
import org.gitlab4j.api.models.Pipeline;
/**
* This class implements the client side API for the GitLab merge request calls.
......@@ -1094,4 +1095,70 @@ public class MergeRequestApi extends AbstractApi {
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid);
return (response.readEntity(MergeRequest.class));
}
/**
* Get a list of pipelines for a merge request.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/pipelines</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param mergeRequestIid the internal ID of the merge request
* @return a list containing the pipelines for the specified merge request
* @throws GitLabApiException if any exception occurs during execution
*/
public List<Pipeline> getMergeRequestPipelines(Object projectIdOrPath, Integer mergeRequestIid) throws GitLabApiException {
return (getMergeRequestPipelines(projectIdOrPath, mergeRequestIid, getDefaultPerPage()).all());
}
/**
* Get a Pager of pipelines for a merge request.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/pipelines</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param mergeRequestIid the internal ID of the merge request
* @param itemsPerPage the number of Pipeline instances that will be fetched per page
* @return a Pager containing the pipelines for the specified merge request
* @throws GitLabApiException if any exception occurs during execution
*/
public Pager<Pipeline> getMergeRequestPipelines(Object projectIdOrPath, Integer mergeRequestIid, int itemsPerPage) throws GitLabApiException {
return (new Pager<Pipeline>(this, Pipeline.class, itemsPerPage, null,
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "pipelines"));
}
/**
* Get a Stream of pipelines for a merge request.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/pipelines</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param mergeRequestIid the internal ID of the merge request
* @return a Stream containing the pipelines for the specified merge request
* @throws GitLabApiException if any exception occurs during execution
*/
public Stream<Pipeline> getMergeRequestPipelinesStream(Object projectIdOrPath, Integer mergeRequestIid) throws GitLabApiException {
return (getMergeRequestPipelines(projectIdOrPath, mergeRequestIid, getDefaultPerPage()).stream());
}
/**
* <p>Create a new pipeline for a merge request. A pipeline created via this endpoint will not run
* a regular branch/tag pipeline, it requires .gitlab-ci.yml to be configured with only:
* [merge_requests] to create jobs.</p>
*
* The new pipeline can be:
* A detached merge request pipeline.
* A pipeline for merged results if the project setting is enabled.
*
* <pre><code>GitLab Endpoint: POST /projects/:id/merge_requests/:merge_request_iid/pipelines</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param mergeRequestIid the internal ID of the merge request
* @return a Pipeline instance with the newly created pipeline info
* @throws GitLabApiException if any exception occurs during execution
*/
public Pipeline createMergeRequestPipeline(Object projectIdOrPath, Integer mergeRequestIid) throws GitLabApiException {
Response response = post(Response.Status.CREATED, (Form)null,
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "pipelines");
return (response.readEntity(Pipeline.class));
}
}
package org.gitlab4j.api.models;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.gitlab4j.api.utils.JacksonJson;
......@@ -15,10 +16,10 @@ public class Pipeline {
private String yamlErrors;
private User user;
private Date createdAt;
private Date updated_at;
private Date started_at;
private Date finished_at;
private Date committed_at;
private Date updatedAt;
private Date startedAt;
private Date finishedAt;
private Date committedAt;
private String coverage;
private Integer duration;
private String webUrl;
......@@ -96,36 +97,116 @@ public class Pipeline {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updated_at) {
this.updatedAt = updated_at;
}
public Date getStartedAt() {
return startedAt;
}
public void setStartedAt(Date started_at) {
this.startedAt = started_at;
}
public Date getFinishedAt() {
return finishedAt;
}
public void setFinishedAt(Date finished_at) {
this.finishedAt = finished_at;
}
public Date getCommittedAt() {
return committedAt;
}
public void setCommittedAt(Date committed_at) {
this.committedAt = committed_at;
}
/**
* @deprecated Replaced by {@link #getUpdatedAt()}
* @return the updated at Date
*/
@Deprecated
@JsonIgnore
public Date getUpdated_at() {
return updated_at;
return updatedAt;
}
public void setUpdated_at(Date updated_at) {
this.updated_at = updated_at;
/**
* @deprecated Replaced by {@link #setUpdatedAt(Date)}
* @param updatedAt new updated at value
*/
@Deprecated
@JsonIgnore
public void setUpdated_at(Date updatedAt) {
this.updatedAt = updatedAt;
}
/**
* @deprecated Replaced by {@link #getStartedAt()}
* @return the started at Date
*/
@Deprecated
@JsonIgnore
public Date getStarted_at() {
return started_at;
return startedAt;
}
public void setStarted_at(Date started_at) {
this.started_at = started_at;
/**
* @deprecated Replaced by {@link #setStartedAt(Date)}
* @param startedAt new started at value
*/
@Deprecated
@JsonIgnore
public void setStarted_at(Date startedAt) {
this.startedAt = startedAt;
}
/**
* @deprecated Replaced by {@link #getFinishedAt()}
* @return the finished at Date
*/
@Deprecated
@JsonIgnore
public Date getFinished_at() {
return finished_at;
return finishedAt;
}
public void setFinished_at(Date finished_at) {
this.finished_at = finished_at;
/**
* @deprecated Replaced by {@link #setFinishedAt(Date)}
* @param finishedAt new finished at value
*/
@Deprecated
@JsonIgnore
public void setFinished_at(Date finishedAt) {
this.finishedAt = finishedAt;
}
/**
* @deprecated Replaced by {@link #getCommittedAt()}
* @return the committed at Date
*/
@Deprecated
@JsonIgnore
public Date getCommitted_at() {
return committed_at;
return committedAt;
}
public void setCommitted_at(Date committed_at) {
this.committed_at = committed_at;
/**
* @deprecated Replaced by {@link #setCommittedAt(Date)}
* @param committedAt new committed at value
*/
@Deprecated
@JsonIgnore
public void setCommitted_at(Date committedAt) {
this.committedAt = committedAt;
}
public String getCoverage() {
......
Supports Markdown
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