Skip to content

Add order_by and sort parameters to pipeline schedules pipelines API

What does this MR do and why?

Adds order_by and sort parameters to the /projects/:id/pipeline_schedules/:pipeline_schedule_id/pipelines API endpoint to allow sorting pipelines by id or created_at in ascending or descending order. This improves efficiency by eliminating the need for multiple paginated requests to fetch the latest pipeline.

  • Validates order_by (id, created_at) and sort (asc, desc) parameters.
  • Uses ActiveRecord order method for sorting.
  • Resolves #369095
  • updated doc openapi_v2.yml

References

Include This issue

How to set up and validate locally

  1. Checkout this branch.
  2. Create a project and a pipeline schedule and a dummy pipeline.
  3. Trigger multiple pipelines using the schedule.
  4. Test the endpoint with curl:
    curl --insecure -XGET --header "PRIVATE-TOKEN: <your_token>" "https://<your_local/gitpod_url>/api/v4/projects/{project_id]/pipeline_schedules/{pipeline_schedule_id}/pipelines?order_by=created_at&sort=desc"
  5. Verify pipelines are sorted by created_at in descending order.

MR acceptance checklist

  • Code follows Ruby style guide.
  • Tests added/updated (added in spec/requests/api/ci/pipeline_schedules_spec.rb).
  • Documentation updated (if needed, in docs/api/pipeline_schedules.md).
  • No breaking changes introduced.
Edited by Nicolas Condomitti

Merge request reports

Loading