From 7599f28d5839e7a4383fc4b747872bd36255b982 Mon Sep 17 00:00:00 2001 From: Vladimir Molodkin Date: Tue, 13 Jun 2023 23:33:14 +0800 Subject: [PATCH] #954 add include_retried for jobs api (#955) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * #954 add include_retried for jobs api * Apply suggestions from code review * Fix compile error --------- Co-authored-by: vladimir.molodkin Co-authored-by: Jérémie Bresson Co-authored-by: Jeremie Bresson --- src/main/java/org/gitlab4j/api/JobApi.java | 40 +++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gitlab4j/api/JobApi.java b/src/main/java/org/gitlab4j/api/JobApi.java index 6b2d4d4c0..93a49bef3 100644 --- a/src/main/java/org/gitlab4j/api/JobApi.java +++ b/src/main/java/org/gitlab4j/api/JobApi.java @@ -139,9 +139,22 @@ public Stream getJobsStream(Object projectIdOrPath, JobScope scope) throws * @throws GitLabApiException if any exception occurs during execution */ public List getJobsForPipeline(Object projectIdOrPath, long pipelineId) throws GitLabApiException { - Response response = get(Response.Status.OK, getDefaultPerPageParam(), - "projects", getProjectIdOrPath(projectIdOrPath), "pipelines", pipelineId, "jobs"); - return (response.readEntity(new GenericType>() {})); + return getJobsForPipeline(projectIdOrPath, pipelineId, (Boolean) null); + } + + /** + * Get a list 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 includeRetried Include retried jobs in the response + * @return a list containing the jobs for the specified project ID and pipeline ID + * @throws GitLabApiException if any exception occurs during execution + */ + public List getJobsForPipeline(Object projectIdOrPath, long pipelineId, Boolean includeRetried) throws GitLabApiException { + return getJobsForPipeline(projectIdOrPath, pipelineId, null, includeRetried); } /** @@ -156,7 +169,26 @@ public List getJobsForPipeline(Object projectIdOrPath, long pipelineId) thr * @throws GitLabApiException if any exception occurs during execution */ public List 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. + * + *
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 scope the scope of jobs, one of: CREATED, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUAL + * @param includeRetried Include retried jobs in the response + * @return a list containing the jobs for the specified project ID and pipeline ID + * @throws GitLabApiException if any exception occurs during execution + */ + public List 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>() {})); }