diff --git a/src/main/java/org/gitlab4j/api/JobApi.java b/src/main/java/org/gitlab4j/api/JobApi.java index 0d7046bbeeaa8504680ab5ef7187c5925f4455b5..de69ed228321618a26679977286f12374ea28ac5 100644 --- a/src/main/java/org/gitlab4j/api/JobApi.java +++ b/src/main/java/org/gitlab4j/api/JobApi.java @@ -162,6 +162,35 @@ public class JobApi extends AbstractApi implements Constants { return (response.readEntity(new GenericType>() {})); } + /** + * Get a Pager of jobs in a pipeline. + * + *
GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/jobs
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the pipelines for + * @param pipelineId the pipeline ID to get the list of jobs for + * @param itemsPerPage the number of Job instances that will be fetched per page + * @return a list containing the jobs for the specified project ID and pipeline ID + * @throws GitLabApiException if any exception occurs during execution + */ + public Pager getJobsForPipeline(Object projectIdOrPath, int pipelineId, int itemsPerPage) throws GitLabApiException { + return (new Pager(this, Job.class, itemsPerPage, getDefaultPerPageParam(), + "projects", getProjectIdOrPath(projectIdOrPath), "pipelines", pipelineId, "jobs")); + } + + /** + * Get a Stream of jobs in a pipeline. + *
GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/jobs
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path + * @param pipelineId the pipeline ID to get the list of jobs for + * @return a Stream containing the jobs for the specified project ID + * @throws GitLabApiException if any exception occurs during execution + */ + public Stream getJobsStream(Object projectIdOrPath, int pipelineId) throws GitLabApiException { + return (getJobsForPipeline(projectIdOrPath, pipelineId, getDefaultPerPage()).stream()); + } + /** * Get single job in a project. *