summaryrefslogtreecommitdiff
path: root/app/models/deployment.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-12-08 06:13:27 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-08 06:13:27 +0000
commit99bcbec56c2f7f8cc3028974ad1d6edcb16a9281 (patch)
tree352560a31119dc737993cce71ed8f5a8f24c698f /app/models/deployment.rb
parent849d5912a8742c628df825043807ad891431cca1 (diff)
downloadgitlab-ce-99bcbec56c2f7f8cc3028974ad1d6edcb16a9281.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/deployment.rb')
-rw-r--r--app/models/deployment.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index bad3a41af2d..4c60ce57f49 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -46,9 +46,10 @@ class Deployment < ApplicationRecord
scope :for_project, -> (project_id) { where(project_id: project_id) }
scope :for_projects, -> (projects) { where(project: projects) }
- scope :visible, -> { where(status: %i[running success failed canceled]) }
+ scope :visible, -> { where(status: %i[running success failed canceled blocked]) }
scope :stoppable, -> { where.not(on_stop: nil).where.not(deployable_id: nil).success }
scope :active, -> { where(status: %i[created running]) }
+ scope :upcoming, -> { where(status: %i[blocked running]) }
scope :older_than, -> (deployment) { where('deployments.id < ?', deployment.id) }
scope :with_api_entity_associations, -> { preload({ deployable: { runner: [], tags: [], user: [], job_artifacts_archive: [] } }) }
@@ -64,6 +65,10 @@ class Deployment < ApplicationRecord
transition created: :running
end
+ event :block do
+ transition created: :blocked
+ end
+
event :succeed do
transition any - [:success] => :success
end
@@ -140,7 +145,8 @@ class Deployment < ApplicationRecord
success: 2,
failed: 3,
canceled: 4,
- skipped: 5
+ skipped: 5,
+ blocked: 6
}
def self.archivables_in(project, limit:)
@@ -391,6 +397,8 @@ class Deployment < ApplicationRecord
cancel!
when 'skipped'
skip!
+ when 'blocked'
+ block!
else
raise ArgumentError, "The status #{status.inspect} is invalid"
end