diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build.rb | 37 | ||||
-rw-r--r-- | app/models/commit_status.rb | 18 |
2 files changed, 27 insertions, 28 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 88a340379b8..92dad9377c9 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -42,24 +42,25 @@ module Ci end def retry(build, user = nil) - new_build = Ci::Build.new(status: 'pending') - new_build.ref = build.ref - new_build.tag = build.tag - new_build.options = build.options - new_build.commands = build.commands - new_build.tag_list = build.tag_list - new_build.project = build.project - new_build.pipeline = build.pipeline - new_build.name = build.name - new_build.allow_failure = build.allow_failure - new_build.stage = build.stage - new_build.stage_idx = build.stage_idx - new_build.trigger_request = build.trigger_request - new_build.yaml_variables = build.yaml_variables - new_build.when = build.when - new_build.user = user - new_build.environment = build.environment - new_build.save + new_build = Ci::Build.create( + ref: build.ref, + tag: build.tag, + options: build.options, + commands: build.commands, + tag_list: build.tag_list, + project: build.project, + pipeline: build.pipeline, + name: build.name, + allow_failure: build.allow_failure, + stage: build.stage, + stage_idx: build.stage_idx, + trigger_request: build.trigger_request, + yaml_variables: build.yaml_variables, + when: build.when, + user: user, + environment: build.environment, + status_event: 'queue' + ) MergeRequests::AddTodoWhenBuildFailsService.new(build.project, nil).close(new_build) new_build end diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 64ce5431d63..522fa5d6911 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -62,14 +62,6 @@ class CommitStatus < ActiveRecord::Base commit_status.update_attributes finished_at: Time.now end - after_transition [:created, :pending, :running] => :success do |commit_status| - MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.pipeline.project, nil).trigger(commit_status) - end - - after_transition any => :failed do |commit_status| - MergeRequests::AddTodoWhenBuildFailsService.new(commit_status.pipeline.project, nil).execute(commit_status) - end - # We use around_transition to process pipeline on next stages as soon as possible, before the `after_*` is executed around_transition any => [:success, :failed, :canceled] do |commit_status, block| block.call @@ -77,11 +69,17 @@ class CommitStatus < ActiveRecord::Base commit_status.pipeline.try(:process!) end - # Try to update the pipeline status - after_transition do |commit_status, transition| commit_status.pipeline.try(:update_status) unless transition.loopback? end + + after_transition [:created, :pending, :running] => :success do |commit_status| + MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.pipeline.project, nil).trigger(commit_status) + end + + after_transition any => :failed do |commit_status| + MergeRequests::AddTodoWhenBuildFailsService.new(commit_status.pipeline.project, nil).execute(commit_status) + end end delegate :sha, :short_sha, to: :pipeline |