diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-11-24 15:58:31 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-11-24 15:58:31 +0100 |
commit | 785d5c8ed15edbabb5704072051569d8db61f4a1 (patch) | |
tree | 4972ba950d880b918879350c2e584053fc607753 /app | |
parent | d5740d3bb6ad23c74e8968f62ec479929c63fb44 (diff) | |
download | gitlab-ce-785d5c8ed15edbabb5704072051569d8db61f4a1.tar.gz |
Create pipeline along with builds in the transation
Diffstat (limited to 'app')
-rw-r--r-- | app/services/ci/create_pipeline_service.rb | 12 | ||||
-rw-r--r-- | app/services/ci/process_pipeline_service.rb | 9 |
2 files changed, 9 insertions, 12 deletions
diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb index cde856b0186..e3bc9847200 100644 --- a/app/services/ci/create_pipeline_service.rb +++ b/app/services/ci/create_pipeline_service.rb @@ -45,9 +45,15 @@ module Ci return error('No builds for this pipeline.') end - pipeline.save - pipeline.process! - pipeline + Ci::Pipeline.transaction do + pipeline.save + + Ci::CreatePipelineBuildsService + .new(project, current_user) + .execute(pipeline) + end + + pipeline.tap(&:process!) end private diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb index 8face432d97..e6bd1d1460c 100644 --- a/app/services/ci/process_pipeline_service.rb +++ b/app/services/ci/process_pipeline_service.rb @@ -5,11 +5,6 @@ module Ci def execute(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 = stage_indexes_of_created_builds.map do |index| process_stage(index) @@ -22,10 +17,6 @@ module Ci private - def create_builds! - Ci::CreatePipelineBuildsService.new(project, current_user).execute(pipeline) - end - def process_stage(index) current_status = status_for_prior_stages(index) |