Class: Projects::UpdatePagesService

Inherits:
BaseService show all
Includes:
Gitlab::InternalEventsTracking, Gitlab::Utils::StrongMemoize
Defined in:
app/services/projects/update_pages_service.rb

Constant Summary collapse

OLD_DEPLOYMENTS_DESTRUCTION_DELAY =

old deployment can be cached by pages daemon so we need to give pages daemon some time update cache 10 minutes is enough, but 30 feels safer

30.minutes

Instance Attribute Summary collapse

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from Gitlab::InternalEventsTracking

#track_internal_event

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

#initialize(project, build) ⇒ UpdatePagesService

Returns a new instance of UpdatePagesService.



15
16
17
18
19
# File 'app/services/projects/update_pages_service.rb', line 15

def initialize(project, build)
  @project = project
  @build = build
  @deployment_validations = ::Gitlab::Pages::DeploymentValidations.new(project, build)
end

Instance Attribute Details

#buildObject (readonly)

Returns the value of attribute build.



13
14
15
# File 'app/services/projects/update_pages_service.rb', line 13

def build
  @build
end

#deployment_validationsObject (readonly)

Returns the value of attribute deployment_validations.



13
14
15
# File 'app/services/projects/update_pages_service.rb', line 13

def deployment_validations
  @deployment_validations
end

Instance Method Details

#executeObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/services/projects/update_pages_service.rb', line 21

def execute
  register_attempt

  ::Ci::Pipelines::AddJobService.new(@build.pipeline).execute!(commit_status) do |job|
    job.enqueue!
    job.run!
  end

  return error(deployment_validations.errors.first.full_message) unless deployment_validations.valid?

  if ::Feature.enabled?(:ff_pages_use_open_file, project)
    handle_deployment_with_open_file
  else
    handle_deployment_with_file
  end
rescue StandardError => e
  error(e.message)
  raise e
end