diff options
-rw-r--r-- | app/models/ci/pipeline.rb | 24 | ||||
-rw-r--r-- | app/services/ci/process_pipeline_service.rb | 2 |
2 files changed, 20 insertions, 6 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index e75fe6c222b..26f1c00286c 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -30,23 +30,23 @@ module Ci end event :run do - transition any => :running + transition any - [:running] => :running end event :skip do - transition any => :skipped + transition any - [:skipped] => :skipped end event :drop do - transition any => :failed + transition any - [:failed] => :failed end event :succeed do - transition any => :success + transition any - [:success] => :success end event :cancel do - transition any => :canceled + transition any - [:canceled] => :canceled end # IMPORTANT @@ -263,6 +263,20 @@ module Ci end def update_status + reload + + can_update = + case latest_builds_status + when 'pending' then can_enqueue? + when 'running' then can_run? + when 'success' then can_succeed? + when 'failed' then can_drop? + when 'canceled' then can_cancel? + when 'skipped' then can_skip? + end + + return unless can_update + with_lock do case latest_builds_status when 'pending' then enqueue diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb index e7a422f9d28..3b255dcc803 100644 --- a/app/services/ci/process_pipeline_service.rb +++ b/app/services/ci/process_pipeline_service.rb @@ -15,7 +15,7 @@ module Ci process_stage(index) end - @pipeline.update_status if new_builds.flatten.any? + @pipeline.update_status new_builds.flatten.any? end |