diff --git a/src/main/java/org/gitlab4j/api/MergeRequestApi.java b/src/main/java/org/gitlab4j/api/MergeRequestApi.java index ec856baf724e020dadaf5c96cdff6336e59ec14a..0896d3bcf8bafdd8fd54ec3c804449c344fdd9da 100644 --- a/src/main/java/org/gitlab4j/api/MergeRequestApi.java +++ b/src/main/java/org/gitlab4j/api/MergeRequestApi.java @@ -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. + * + *
GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/pipelines
+ * + * @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 getMergeRequestPipelines(Object projectIdOrPath, Integer mergeRequestIid) throws GitLabApiException { + return (getMergeRequestPipelines(projectIdOrPath, mergeRequestIid, getDefaultPerPage()).all()); + } + + /** + * Get a Pager of pipelines for a merge request. + * + *
GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/pipelines
+ * + * @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 getMergeRequestPipelines(Object projectIdOrPath, Integer mergeRequestIid, int itemsPerPage) throws GitLabApiException { + return (new Pager(this, Pipeline.class, itemsPerPage, null, + "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "pipelines")); + } + + /** + * Get a Stream of pipelines for a merge request. + * + *
GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/pipelines
+ * + * @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 getMergeRequestPipelinesStream(Object projectIdOrPath, Integer mergeRequestIid) throws GitLabApiException { + return (getMergeRequestPipelines(projectIdOrPath, mergeRequestIid, getDefaultPerPage()).stream()); + } + + /** + *

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.

+ * + * The new pipeline can be: + * A detached merge request pipeline. + * A pipeline for merged results if the project setting is enabled. + * + *
GitLab Endpoint: POST /projects/:id/merge_requests/:merge_request_iid/pipelines
+ * + * @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)); + } } diff --git a/src/main/java/org/gitlab4j/api/models/Pipeline.java b/src/main/java/org/gitlab4j/api/models/Pipeline.java index 84ff648bf194c740128b8629d0fb475562a04e8d..c4d3e70945be437126acdf8fb3d0a8348287fbcf 100644 --- a/src/main/java/org/gitlab4j/api/models/Pipeline.java +++ b/src/main/java/org/gitlab4j/api/models/Pipeline.java @@ -1,6 +1,7 @@ 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() {