Commit 39fc0d50 authored by Allison Browne's avatar Allison Browne Committed by Fabio Pitino

Add changelog for:

Bug Fix: Child pipelines are not found by API endpoint
parent 1ad2429e
......@@ -63,6 +63,10 @@ module Ci
def self.ci_config_sources_values
ci_config_sources.values
end
def self.non_ci_config_source_values
config_sources.values - ci_config_sources.values
end
end
end
......
---
title: 'Bug Fix: Child pipelines are not found by API endpoints'
merge_request: 36494
author:
type: fixed
......@@ -269,6 +269,9 @@ Example of response
]
```
Since GitLab 13.2, this endpoint [returns data for any pipeline](pipelines.md#single-pipeline-requests)
including [child pipelines](../ci/parent_child_pipelines.md).
## List pipeline bridges
Get a list of bridge jobs for a pipeline.
......
# Pipelines API
## Single Pipeline Requests
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/36494) in GitLab 13.2.
Endpoints that request information about a single pipeline return data for any pipeline.
Before 13.2, requests for [child pipelines](../ci/parent_child_pipelines.md) returned
a 404 error.
## Pipelines pagination
By default, `GET` requests return 20 results at a time because the API results
......
......@@ -174,7 +174,7 @@ module API
helpers do
def pipeline
strong_memoize(:pipeline) do
user_project.ci_pipelines.find(params[:pipeline_id])
user_project.all_pipelines.find(params[:pipeline_id])
end
end
......
......@@ -59,7 +59,7 @@ module API
# rubocop: disable CodeReuse/ActiveRecord
get ':id/pipelines/:pipeline_id/jobs' do
authorize!(:read_pipeline, user_project)
pipeline = user_project.ci_pipelines.find(params[:pipeline_id])
pipeline = user_project.all_pipelines.find(params[:pipeline_id])
authorize!(:read_build, pipeline)
builds = pipeline.builds
......
......@@ -438,7 +438,7 @@ RSpec.describe API::Ci::Pipelines do
expect(response).to match_response_schema('public_api/v4/pipeline/detail')
end
it 'returns project pipelines' do
it 'returns project pipeline' do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}", user)
expect(response).to have_gitlab_http_status(:ok)
......@@ -475,6 +475,20 @@ RSpec.describe API::Ci::Pipelines do
expect(json_response['id']).to be nil
end
end
context 'when config source is not ci' do
let(:non_ci_config_source) { ::Ci::PipelineEnums.non_ci_config_source_values.first }
let(:pipeline_not_ci) do
create(:ci_pipeline, config_source: non_ci_config_source, project: project)
end
it 'returns the specified pipeline' do
get api("/projects/#{project.id}/pipelines/#{pipeline_not_ci.id}", user)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['sha']).to eq(pipeline_not_ci.sha)
end
end
end
describe 'GET /projects/:id/pipelines/latest' do
......
......@@ -239,6 +239,18 @@ RSpec.describe API::Jobs do
end
end
context 'when config source not ci' do
let(:non_ci_config_source) { ::Ci::PipelineEnums.non_ci_config_source_values.first }
let(:pipeline) do
create(:ci_pipeline, config_source: non_ci_config_source, project: project)
end
it 'returns the specified pipeline' do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response[0]['pipeline']['sha']).to eq(pipeline.sha.to_s)
end
end
it 'avoids N+1 queries' do
control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), params: query
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment