Skip to content

Commit 0b9ac1d

Browse files
authored
Merge pull request #692 from opensource21/Fix-631
Added Paging- and Stream-Support for Jobs in Pipeline.
2 parents 18d6902 + fde7749 commit 0b9ac1d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/main/java/org/gitlab4j/api/JobApi.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,35 @@ public List<Job> getJobsForPipeline(Object projectIdOrPath, int pipelineId, JobS
162162
return (response.readEntity(new GenericType<List<Job>>() {}));
163163
}
164164

165+
/**
166+
* Get a Pager of jobs in a pipeline.
167+
*
168+
* <pre><code>GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/jobs</code></pre>
169+
*
170+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the pipelines for
171+
* @param pipelineId the pipeline ID to get the list of jobs for
172+
* @param itemsPerPage the number of Job instances that will be fetched per page
173+
* @return a list containing the jobs for the specified project ID and pipeline ID
174+
* @throws GitLabApiException if any exception occurs during execution
175+
*/
176+
public Pager<Job> getJobsForPipeline(Object projectIdOrPath, int pipelineId, int itemsPerPage) throws GitLabApiException {
177+
return (new Pager<Job>(this, Job.class, itemsPerPage, getDefaultPerPageParam(),
178+
"projects", getProjectIdOrPath(projectIdOrPath), "pipelines", pipelineId, "jobs"));
179+
}
180+
181+
/**
182+
* Get a Stream of jobs in a pipeline.
183+
* <pre><code>GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/jobs</code></pre>
184+
*
185+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
186+
* @param pipelineId the pipeline ID to get the list of jobs for
187+
* @return a Stream containing the jobs for the specified project ID
188+
* @throws GitLabApiException if any exception occurs during execution
189+
*/
190+
public Stream<Job> getJobsStream(Object projectIdOrPath, int pipelineId) throws GitLabApiException {
191+
return (getJobsForPipeline(projectIdOrPath, pipelineId, getDefaultPerPage()).stream());
192+
}
193+
165194
/**
166195
* Get single job in a project.
167196
*

0 commit comments

Comments
 (0)