Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/deployment.rb')
-rw-r--r--app/models/deployment.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index 68f50b13a07..fe42fb93633 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -41,6 +41,9 @@ class Deployment < ApplicationRecord
scope :visible, -> { where(status: %i[running success failed canceled]) }
scope :stoppable, -> { where.not(on_stop: nil).where.not(deployable_id: nil).success }
+ scope :active, -> { where(status: %i[created running]) }
+ scope :older_than, -> (deployment) { where('id < ?', deployment.id) }
+ scope :with_deployable, -> { includes(:deployable).where('deployable_id IS NOT NULL') }
state_machine :status, initial: :created do
event :run do
@@ -74,6 +77,14 @@ class Deployment < ApplicationRecord
Deployments::FinishedWorker.perform_async(id)
end
end
+
+ after_transition any => :running do |deployment|
+ next unless deployment.project.forward_deployment_enabled?
+
+ deployment.run_after_commit do
+ Deployments::ForwardDeploymentWorker.perform_async(id)
+ end
+ end
end
enum status: {