Commit 785d5c8e authored by Grzegorz Bizon's avatar Grzegorz Bizon

Create pipeline along with builds in the transation

parent d5740d3b
...@@ -45,9 +45,15 @@ module Ci ...@@ -45,9 +45,15 @@ module Ci
return error('No builds for this pipeline.') return error('No builds for this pipeline.')
end end
pipeline.save Ci::Pipeline.transaction do
pipeline.process! pipeline.save
pipeline
Ci::CreatePipelineBuildsService
.new(project, current_user)
.execute(pipeline)
end
pipeline.tap(&:process!)
end end
private private
......
...@@ -5,11 +5,6 @@ module Ci ...@@ -5,11 +5,6 @@ module Ci
def execute(pipeline) def execute(pipeline)
@pipeline = pipeline @pipeline = pipeline
# This method will ensure that our pipeline does have all builds for all stages created
if created_builds.empty?
create_builds!
end
new_builds = new_builds =
stage_indexes_of_created_builds.map do |index| stage_indexes_of_created_builds.map do |index|
process_stage(index) process_stage(index)
...@@ -22,10 +17,6 @@ module Ci ...@@ -22,10 +17,6 @@ module Ci
private private
def create_builds!
Ci::CreatePipelineBuildsService.new(project, current_user).execute(pipeline)
end
def process_stage(index) def process_stage(index)
current_status = status_for_prior_stages(index) current_status = status_for_prior_stages(index)
......
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