diff --git a/app/finders/ci/pipelines_finder.rb b/app/finders/ci/pipelines_finder.rb index b3aefe6fa448b4440e56ada6958960694828ba67..a17103cd48a2816e4eb1a711d9f1418d1147f68c 100644 --- a/app/finders/ci/pipelines_finder.rb +++ b/app/finders/ci/pipelines_finder.rb @@ -25,8 +25,7 @@ def initialize(project, current_user, params = {}) def execute return Ci::Pipeline.none unless Ability.allowed?(current_user, :read_pipeline, project) - items = pipelines - items = items.no_child unless params[:iids].present? + items = prefiltered_pipelines items = by_iids(items) items = by_scope(items) items = by_status(items) @@ -63,6 +62,13 @@ def tags project.repository.tag_names end + def prefiltered_pipelines + return pipelines if params[:iids].present? + return pipelines if params[:source] == 'parent_pipeline' + + pipelines.no_child + end + def by_iids(items) if params[:iids].present? items.for_iid(params[:iids]) diff --git a/doc/api/pipelines.md b/doc/api/pipelines.md index b4766aa7b9fa5bdf397c0b5e16fd5bfea3c7f586..93b4a07773db89a83ab19cc3bfeac1a2dbe38d06 100644 --- a/doc/api/pipelines.md +++ b/doc/api/pipelines.md @@ -24,9 +24,12 @@ Read more on [pagination](rest/index.md#pagination). > - `name` in request [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/115310) in 15.11 [with a flag](../administration/feature_flags.md) named `pipeline_name_search`. Disabled by default. > - `name` in response [generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/398131) in GitLab 16.3. Feature flag `pipeline_name_in_api` removed. > - `name` in request [generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/385864) in GitLab 16.9. Feature flag `pipeline_name_search` removed. +> - Support for returning child pipelines with `source` set to `parent_pipeline` [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/39503) in GitLab 17.0. -List pipelines in a project. Child pipelines are not included in the results, -but you can [get child pipeline](pipelines.md#get-a-single-pipeline) individually. +List pipelines in a project. + +By default, [child pipelines](../ci/pipelines/downstream_pipelines.md#parent-child-pipelines) +are not included in the results. To return child pipelines, set `source` to `parent_pipeline`. ```plaintext GET /projects/:id/pipelines diff --git a/spec/finders/ci/pipelines_finder_spec.rb b/spec/finders/ci/pipelines_finder_spec.rb index 7a94c8191f5547e13203ce38f8491892d38fecd4..bb3b603976b9a7ae5b196d54b759cb8e9b731cff 100644 --- a/spec/finders/ci/pipelines_finder_spec.rb +++ b/spec/finders/ci/pipelines_finder_spec.rb @@ -75,6 +75,14 @@ it 'filters out child pipelines and shows only the parents by default' do is_expected.to eq([parent_pipeline]) end + + context 'when source is parent_pipeline' do + let(:params) { { source: 'parent_pipeline' } } + + it 'does not filter out child pipelines' do + is_expected.to eq([child_pipeline]) + end + end end Ci::HasStatus::AVAILABLE_STATUSES.each do |target|