Merge branch 'fix/sm/37040-regression-pipeline-trigger-via-api-fails-with-500-internal-server-error-in-9-5-1' into 'master'
Fix pipeline trigger via API fails with 500 Internal Server Error in 9.5.1 Closes #37040 See merge request !13861
This commit is contained in:
commit
01785533a5
4 changed files with 33 additions and 16 deletions
|
@ -15,7 +15,7 @@ module Ci
|
|||
pipeline_schedule: schedule
|
||||
)
|
||||
|
||||
result = validate(current_user || trigger_request.trigger.owner,
|
||||
result = validate(current_user,
|
||||
ignore_skip_ci: ignore_skip_ci,
|
||||
save_on_errors: save_on_errors)
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix pipeline trigger via API fails with 500 Internal Server Error in 9.5
|
||||
merge_request:
|
||||
author:
|
||||
type: fixed
|
|
@ -84,6 +84,22 @@ describe API::Triggers do
|
|||
expect(pipeline.variables.map { |v| { v.key => v.value } }.last).to eq(variables)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when legacy trigger' do
|
||||
before do
|
||||
trigger.update(owner: nil)
|
||||
end
|
||||
|
||||
it 'creates pipeline' do
|
||||
post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'master')
|
||||
|
||||
expect(response).to have_http_status(201)
|
||||
expect(json_response).to include('id' => pipeline.id)
|
||||
pipeline.builds.reload
|
||||
expect(pipeline.builds.pending.size).to eq(2)
|
||||
expect(pipeline.builds.size).to eq(5)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when triggering a pipeline from a trigger token' do
|
||||
|
|
|
@ -413,14 +413,12 @@ describe Ci::CreatePipelineService do
|
|||
end
|
||||
|
||||
context 'when trigger belongs to a developer' do
|
||||
let(:user) {}
|
||||
let(:user) { create(:user) }
|
||||
let(:trigger) { create(:ci_trigger, owner: user) }
|
||||
let(:trigger_request) { create(:ci_trigger_request, trigger: trigger) }
|
||||
|
||||
let(:trigger_request) do
|
||||
create(:ci_trigger_request).tap do |request|
|
||||
user = create(:user)
|
||||
project.add_developer(user)
|
||||
request.trigger.update(owner: user)
|
||||
end
|
||||
before do
|
||||
project.add_developer(user)
|
||||
end
|
||||
|
||||
it 'does not create a pipeline' do
|
||||
|
@ -431,17 +429,15 @@ describe Ci::CreatePipelineService do
|
|||
end
|
||||
|
||||
context 'when trigger belongs to a master' do
|
||||
let(:user) {}
|
||||
let(:user) { create(:user) }
|
||||
let(:trigger) { create(:ci_trigger, owner: user) }
|
||||
let(:trigger_request) { create(:ci_trigger_request, trigger: trigger) }
|
||||
|
||||
let(:trigger_request) do
|
||||
create(:ci_trigger_request).tap do |request|
|
||||
user = create(:user)
|
||||
project.add_master(user)
|
||||
request.trigger.update(owner: user)
|
||||
end
|
||||
before do
|
||||
project.add_master(user)
|
||||
end
|
||||
|
||||
it 'does not create a pipeline' do
|
||||
it 'creates a pipeline' do
|
||||
expect(execute_service(trigger_request: trigger_request))
|
||||
.to be_persisted
|
||||
expect(Ci::Pipeline.count).to eq(1)
|
||||
|
|
Loading…
Reference in a new issue