diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /app/models/deployment.rb | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'app/models/deployment.rb')
-rw-r--r-- | app/models/deployment.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb index ade19ce02a8..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 @@ -119,6 +124,8 @@ class Deployment < ApplicationRecord next if transition.loopback? deployment.run_after_commit do + next unless deployment.project.jira_subscription_exists? + ::JiraConnect::SyncDeploymentsWorker.perform_async(id) end end @@ -126,6 +133,8 @@ class Deployment < ApplicationRecord after_create unless: :importing? do |deployment| run_after_commit do + next unless deployment.project.jira_subscription_exists? + ::JiraConnect::SyncDeploymentsWorker.perform_async(deployment.id) end end @@ -136,7 +145,8 @@ class Deployment < ApplicationRecord success: 2, failed: 3, canceled: 4, - skipped: 5 + skipped: 5, + blocked: 6 } def self.archivables_in(project, limit:) @@ -387,6 +397,8 @@ class Deployment < ApplicationRecord cancel! when 'skipped' skip! + when 'blocked' + block! else raise ArgumentError, "The status #{status.inspect} is invalid" end |