Class: Deployments::AfterCreateService

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deployment) ⇒ AfterCreateService

Returns a new instance of AfterCreateService.


12
13
14
15
# File 'app/services/deployments/after_create_service.rb', line 12

def initialize(deployment)
  @deployment = deployment
  @deployable = deployment.deployable
end

Instance Attribute Details

#deployableObject (readonly)

Returns the value of attribute deployable


6
7
8
# File 'app/services/deployments/after_create_service.rb', line 6

def deployable
  @deployable
end

#deploymentObject (readonly)

Returns the value of attribute deployment


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

def deployment
  @deployment
end

Instance Method Details

#executeObject


17
18
19
20
21
22
23
24
# File 'app/services/deployments/after_create_service.rb', line 17

def execute
  deployment.create_ref
  deployment.invalidate_cache

  update_environment(deployment)

  deployment
end

#update_environment(deployment) ⇒ Object


26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/services/deployments/after_create_service.rb', line 26

def update_environment(deployment)
  ActiveRecord::Base.transaction do
    if (url = expanded_environment_url)
      environment.external_url = url
    end

    renew_auto_stop_in
    environment.fire_state_event(action)

    if environment.save && !environment.stopped?
      deployment.update_merge_request_metrics!
    end
  end
end