Skip to content

#954 add include_retried for jobs api #955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions src/main/java/org/gitlab4j/api/JobApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,24 @@ public Stream<Job> getJobsStream(Object projectIdOrPath, JobScope scope) throws
* @throws GitLabApiException if any exception occurs during execution
*/
public List<Job> getJobsForPipeline(Object projectIdOrPath, long pipelineId) throws GitLabApiException {
Response response = get(Response.Status.OK, getDefaultPerPageParam(),
"projects", getProjectIdOrPath(projectIdOrPath), "pipelines", pipelineId, "jobs");
return getJobsForPipeline(projectIdOrPath, pipelineId, false);
}

/**
* Get a list of jobs in a pipeline.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/jobs</code></pre>
*
* @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 includeRetried the includeRetried to get also retried jobs
* @return a list containing the jobs for the specified project ID and pipeline ID
* @throws GitLabApiException if any exception occurs during execution
*/
public List<Job> getJobsForPipeline(Object projectIdOrPath, long pipelineId, boolean includeRetried) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm().withParam("include_retried", includeRetried).withParam(PER_PAGE_PARAM, getDefaultPerPage());
Response response = get(Response.Status.OK, formData.asMap(),
"projects", getProjectIdOrPath(projectIdOrPath), "pipelines", pipelineId, "jobs");
return (response.readEntity(new GenericType<List<Job>>() {}));
}

Expand All @@ -156,7 +172,23 @@ public List<Job> getJobsForPipeline(Object projectIdOrPath, long pipelineId) thr
* @throws GitLabApiException if any exception occurs during execution
*/
public List<Job> getJobsForPipeline(Object projectIdOrPath, long pipelineId, JobScope scope) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm().withParam("scope", scope).withParam(PER_PAGE_PARAM, getDefaultPerPage());
return getJobsForPipeline(projectIdOrPath, pipelineId, scope, false);
}

/**
* Get a list of jobs in a pipeline.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/jobs</code></pre>
*
* @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 scope the scope of jobs, one of: CREATED, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUAL
* @param includeRetried the includeRetried to get also retried jobs
* @return a list containing the jobs for the specified project ID and pipeline ID
* @throws GitLabApiException if any exception occurs during execution
*/
public List<Job> getJobsForPipeline(Object projectIdOrPath, long pipelineId, JobScope scope, boolean includeRetried) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm().withParam("scope", scope).withParam("include_retried", includeRetried).withParam(PER_PAGE_PARAM, getDefaultPerPage());
Response response = get(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "pipelines", pipelineId, "jobs");
return (response.readEntity(new GenericType<List<Job>>() {}));
}
Expand Down