Class: Releases::CreateService

Inherits:
BaseService show all
Defined in:
app/services/releases/create_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#description, #execute_hooks, #existing_tag, #inexistent_milestones, #initialize, #milestones, #name, #param_for_milestone_titles_provided?, #project_group_id, #ref, #release, #released_at, #repository, #tag_name

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

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?

Constructor Details

This class inherits a constructor from Releases::BaseService

Instance Method Details

#executeObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/services/releases/create_service.rb', line 5

def execute
  return error('Access Denied', 403) unless allowed?
  return error('Release already exists', 409) if release
  return error("Milestone(s) not found: #{inexistent_milestones.join(', ')}", 400) if inexistent_milestones.any?

  # should be found before the creation of new tag
  # because tag creation can spawn new pipeline
  # which won't have any data for evidence yet
  evidence_pipeline = Releases::EvidencePipelineFinder.new(project, params).execute

  tag = ensure_tag

  return tag unless tag.is_a?(Gitlab::Git::Tag)

  create_release(tag, evidence_pipeline)
end

#find_or_build_releaseObject


22
23
24
# File 'app/services/releases/create_service.rb', line 22

def find_or_build_release
  release || build_release(existing_tag)
end