diff options
| author | Shinya Maeda <shinya@gitlab.com> | 2018-09-21 15:24:19 +0900 |
|---|---|---|
| committer | Alessio Caiazza <acaiazza@gitlab.com> | 2018-10-02 17:02:11 +0200 |
| commit | 1a4f497e6093c8d1005986467c8b752cc61c6629 (patch) | |
| tree | 4ad50ce8528809d31af31ea981328a3a86924b5f /app | |
| parent | a7c767f16446f71f6e35a5aa3d2fdc73037fcdf5 (diff) | |
| download | gitlab-ce-1a4f497e6093c8d1005986467c8b752cc61c6629.tar.gz | |
Update pipelines and stages status as well
Diffstat (limited to 'app')
| -rw-r--r-- | app/helpers/ci_status_helper.rb | 1 | ||||
| -rw-r--r-- | app/models/ci/build.rb | 4 | ||||
| -rw-r--r-- | app/models/ci/pipeline.rb | 5 | ||||
| -rw-r--r-- | app/models/ci/stage.rb | 5 | ||||
| -rw-r--r-- | app/models/concerns/has_status.rb | 2 |
5 files changed, 15 insertions, 2 deletions
diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb index 136772e1ec3..f343607a343 100644 --- a/app/helpers/ci_status_helper.rb +++ b/app/helpers/ci_status_helper.rb @@ -7,6 +7,7 @@ # # See 'detailed_status?` method and `Gitlab::Ci::Status` module. # +# TODO: DO I need to update this deprecated module? module CiStatusHelper def ci_label_for_status(status) if detailed_status?(status) diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 3ef149f3632..cf5df2ca354 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -169,11 +169,11 @@ module Ci end before_transition created: :scheduled do |build| - build_build_schedule(execute_at: execute_at) + build.build_build_schedule(execute_at: build.execute_at) end before_transition scheduled: any do |build| - build_schedule.delete! + build.build_schedule.delete end after_transition any => [:pending] do |build| diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 6dac577c514..2d90c9bfe50 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -108,6 +108,10 @@ module Ci transition any - [:manual] => :manual end + event :schedule do + transition any - [:scheduled] => :scheduled + end + # IMPORTANT # Do not add any operations to this state_machine # Create a separate worker for each new operation @@ -544,6 +548,7 @@ module Ci when 'canceled' then cancel when 'skipped' then skip when 'manual' then block + when 'scheduled' then schedule else raise HasStatus::UnknownStatusError, "Unknown status `#{latest_builds_status}`" diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index 511ded55dc3..811261a252e 100644 --- a/app/models/ci/stage.rb +++ b/app/models/ci/stage.rb @@ -65,6 +65,10 @@ module Ci event :block do transition any - [:manual] => :manual end + + event :schedule do + transition any - [:scheduled] => :scheduled + end end def update_status @@ -77,6 +81,7 @@ module Ci when 'failed' then drop when 'canceled' then cancel when 'manual' then block + when 'scheduled' then schedule when 'skipped', nil then skip else raise HasStatus::UnknownStatusError, diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb index 0a97e4cdfc4..652f56f7f11 100644 --- a/app/models/concerns/has_status.rb +++ b/app/models/concerns/has_status.rb @@ -77,6 +77,7 @@ module HasStatus state :canceled, value: 'canceled' state :skipped, value: 'skipped' state :manual, value: 'manual' + state :scheduled, value: 'scheduled' end scope :created, -> { where(status: 'created') } @@ -88,6 +89,7 @@ module HasStatus scope :canceled, -> { where(status: 'canceled') } scope :skipped, -> { where(status: 'skipped') } scope :manual, -> { where(status: 'manual') } + scope :scheduled, -> { where(status: 'scheduled') } scope :alive, -> { where(status: [:created, :pending, :running]) } scope :created_or_pending, -> { where(status: [:created, :pending]) } scope :running_or_pending, -> { where(status: [:running, :pending]) } |
