Class: Deployments::OlderDeploymentsDropService

Inherits:
Object
  • Object
show all
Defined in:
app/services/deployments/older_deployments_drop_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deployment_id) ⇒ OlderDeploymentsDropService

Returns a new instance of OlderDeploymentsDropService.


7
8
9
# File 'app/services/deployments/older_deployments_drop_service.rb', line 7

def initialize(deployment_id)
  @deployment = Deployment.find_by_id(deployment_id)
end

Instance Attribute Details

#deploymentObject (readonly)

Returns the value of attribute deployment.


5
6
7
# File 'app/services/deployments/older_deployments_drop_service.rb', line 5

def deployment
  @deployment
end

Instance Method Details

#executeObject


11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/deployments/older_deployments_drop_service.rb', line 11

def execute
  return unless @deployment&.running?

  older_deployments_builds.each do |build|
    next if build.manual?

    Gitlab::OptimisticLocking.retry_lock(build, name: 'older_deployments_drop') do |build|
      build.drop(:forward_deployment_failure)
    end
  rescue StandardError => e
    Gitlab::ErrorTracking.track_exception(e, subject_id: @deployment.id, build_id: build.id)
  end
end