Expose project details in the user pipelines API
What does this MR do and why?
The instance-level endpoint GET /pipelines (introduced in !250635 (merged)) lists pipelines triggered by the authenticated user, but each entry only included project_id. Consumers who wanted to display a project name had to make an extra request per project.
This MR adds a project object to each pipeline entry in the response, containing basic project identity fields.
Implementation
- Adds
API::Entities::Ci::PipelineBasicWithProject, which subclassesPipelineBasicWithMetadataand exposesprojectusing the existingAPI::Entities::ProjectIdentityentity (id,description,name,name_with_namespace,path,path_with_namespace,created_at). lib/api/ci/user_pipelines.rbnow presents this new entity instead ofPipelineBasicWithMetadata.- Updates
doc/api/pipelines.md(history note and example responses) and regeneratesdoc/api/openapi/openapi_v3.yaml.
Performance
No additional database queries are issued. The endpoint already scopes pipelines with Ci::Pipeline.with_api_entity_associations, which preloads the project along with its route and namespace route (PROJECT_ROUTE_AND_NAMESPACE_ROUTE) because building web_url already required them. The newly exposed project attributes read only from these already-preloaded records.
This is verified by the existing N+1 QueryRecorder spec in spec/requests/api/ci/user_pipelines_spec.rb ("avoids N+1 queries when pipelines from more projects are returned"), which still passes unchanged (21 examples, 0 failures).
The response payload grows by seven small scalar fields per pipeline, with at most 100 pipelines per page.
Backwards compatibility
This is a purely additive change: a new response field. No fields are removed, renamed, or change type, which is non-breaking under REST API v4 compatibility guidelines.
PipelineBasicWithMetadata itself is untouched, so GET /projects/:id/pipelines, which also uses it, returns exactly the same payload as before. The new entity is used only by GET /pipelines.
No changes to authentication, authorization, parameters, or status codes.
How to set up and validate locally
-
Run GDK.
-
Trigger or seed a pipeline as your user.
-
Run:
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" --url "http://gdk.test:3000/api/v4/pipelines?per_page=5" -
Confirm each entry in the response contains a
projectobject.