Class: Ci::Workloads::WorkloadBranchService
- Inherits:
-
Object
- Object
- Ci::Workloads::WorkloadBranchService
- Defined in:
- app/services/ci/workloads/workload_branch_service.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(project:, source_branch:, current_user:) ⇒ WorkloadBranchService
constructor
A new instance of WorkloadBranchService.
Constructor Details
#initialize(project:, source_branch:, current_user:) ⇒ WorkloadBranchService
Returns a new instance of WorkloadBranchService.
6 7 8 9 10 |
# File 'app/services/ci/workloads/workload_branch_service.rb', line 6 def initialize(project:, source_branch:, current_user:) @project = project @current_user = current_user @source_branch = source_branch end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/services/ci/workloads/workload_branch_service.rb', line 12 def execute workload_ref = "workloads/#{SecureRandom.hex[0..10]}" source_ref = @project.repository.branch_exists?(@source_branch) ? @source_branch : default_branch if Feature.enabled?(:use_internal_refs_for_workload_pipelines, @project) create_internal_refs(source_ref, workload_ref) else create_workload_branch(source_ref, workload_ref) end rescue Gitlab::Git::CommandError => e Gitlab::ErrorTracking.track_exception(e) ServiceResponse.error(message: 'Failed to create workload ref') end |