Commit 01785533 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch...

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
parents 418f01a6 4401b759
...@@ -15,7 +15,7 @@ module Ci ...@@ -15,7 +15,7 @@ module Ci
pipeline_schedule: schedule pipeline_schedule: schedule
) )
result = validate(current_user || trigger_request.trigger.owner, result = validate(current_user,
ignore_skip_ci: ignore_skip_ci, ignore_skip_ci: ignore_skip_ci,
save_on_errors: save_on_errors) save_on_errors: save_on_errors)
......
---
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 ...@@ -84,6 +84,22 @@ describe API::Triggers do
expect(pipeline.variables.map { |v| { v.key => v.value } }.last).to eq(variables) expect(pipeline.variables.map { |v| { v.key => v.value } }.last).to eq(variables)
end end
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 end
context 'when triggering a pipeline from a trigger token' do context 'when triggering a pipeline from a trigger token' do
......
...@@ -413,14 +413,12 @@ describe Ci::CreatePipelineService do ...@@ -413,14 +413,12 @@ describe Ci::CreatePipelineService do
end end
context 'when trigger belongs to a developer' do 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 before do
create(:ci_trigger_request).tap do |request|
user = create(:user)
project.add_developer(user) project.add_developer(user)
request.trigger.update(owner: user)
end
end end
it 'does not create a pipeline' do it 'does not create a pipeline' do
...@@ -431,17 +429,15 @@ describe Ci::CreatePipelineService do ...@@ -431,17 +429,15 @@ describe Ci::CreatePipelineService do
end end
context 'when trigger belongs to a master' do 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 before do
create(:ci_trigger_request).tap do |request|
user = create(:user)
project.add_master(user) project.add_master(user)
request.trigger.update(owner: user)
end
end end
it 'does not create a pipeline' do it 'creates a pipeline' do
expect(execute_service(trigger_request: trigger_request)) expect(execute_service(trigger_request: trigger_request))
.to be_persisted .to be_persisted
expect(Ci::Pipeline.count).to eq(1) expect(Ci::Pipeline.count).to eq(1)
......
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