diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-08-29 12:15:43 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-08-29 12:15:43 +0000 |
commit | 01785533a5ba26e9dbed7972d9732a9b122ff3e0 (patch) | |
tree | 0b50f09dd6c5d04f68a620e80869eaba4c4cc5a9 | |
parent | 418f01a6c4ccfafcad043122465357e38b7b462e (diff) | |
parent | 4401b7595510a6126a1d38b5743113777ad9aa2f (diff) | |
download | gitlab-ce-01785533a5ba26e9dbed7972d9732a9b122ff3e0.tar.gz |
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
4 files changed, 33 insertions, 16 deletions
diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb index d0ba9f89460..de2cd7e87be 100644 --- a/app/services/ci/create_pipeline_service.rb +++ b/app/services/ci/create_pipeline_service.rb @@ -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) diff --git a/changelogs/unreleased/fix-sm-37040-regression-pipeline-trigger-via-api-fails-with-500-internal-server-error-in-9-5-1.yml b/changelogs/unreleased/fix-sm-37040-regression-pipeline-trigger-via-api-fails-with-500-internal-server-error-in-9-5-1.yml new file mode 100644 index 00000000000..fb97bdb6b30 --- /dev/null +++ b/changelogs/unreleased/fix-sm-37040-regression-pipeline-trigger-via-api-fails-with-500-internal-server-error-in-9-5-1.yml @@ -0,0 +1,5 @@ +--- +title: Fix pipeline trigger via API fails with 500 Internal Server Error in 9.5 +merge_request: +author: +type: fixed diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb index 1e206fd2a9e..402d1040436 100644 --- a/spec/requests/api/triggers_spec.rb +++ b/spec/requests/api/triggers_spec.rb @@ -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 diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index fdd0cea4f3b..4ba3dada37c 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -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) |