summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2017-07-28 11:43:00 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2017-07-28 11:43:00 +0000
commitfa1e41ea646655ee87f80d76e7ae0b84bd75fbc7 (patch)
tree4be574f9adb43c1058d5805abf0c097018da48c6 /lib
parent8626cdc3b3fcb18447c65588327a7d7c16121305 (diff)
parentdca9bd9e6978cc240565e09de34c1387d7249294 (diff)
downloadgitlab-ce-fa1e41ea646655ee87f80d76e7ae0b84bd75fbc7.tar.gz
Merge branch 'feature/sm/35282-ci_pipeline_variables-2' into 'master'
Follow-up from "Allow to use cross project pipelines" ver 2 Closes #35282, gitlab-ee#2604, and #35584 See merge request !13102
Diffstat (limited to 'lib')
-rw-r--r--lib/api/triggers.rb23
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/api/triggers.rb b/lib/api/triggers.rb
index 9375e7eb768..edfdb63d183 100644
--- a/lib/api/triggers.rb
+++ b/lib/api/triggers.rb
@@ -15,25 +15,22 @@ module API
optional :variables, type: Hash, desc: 'The list of variables to be injected into build'
end
post ":id/(ref/:ref/)trigger/pipeline", requirements: { ref: /.+/ } do
- project = find_project(params[:id])
- trigger = Ci::Trigger.find_by_token(params[:token].to_s)
- not_found! unless project && trigger
- unauthorized! unless trigger.project == project
-
# validate variables
- variables = params[:variables].to_h
- unless variables.all? { |key, value| key.is_a?(String) && value.is_a?(String) }
+ params[:variables] = params[:variables].to_h
+ unless params[:variables].all? { |key, value| key.is_a?(String) && value.is_a?(String) }
render_api_error!('variables needs to be a map of key-valued strings', 400)
end
- # create request and trigger builds
- result = Ci::CreateTriggerRequestService.execute(project, trigger, params[:ref].to_s, variables)
- pipeline = result.pipeline
+ project = find_project(params[:id])
+ not_found! unless project
+
+ result = Ci::PipelineTriggerService.new(project, nil, params).execute
+ not_found! unless result
- if pipeline.persisted?
- present pipeline, with: Entities::Pipeline
+ if result[:http_status]
+ render_api_error!(result[:message], result[:http_status])
else
- render_validation_error!(pipeline)
+ present result[:pipeline], with: Entities::Pipeline
end
end