Class: Ci::TriggerDownstreamPipelineService

Inherits:
Object
  • Object
show all
Defined in:
app/services/ci/trigger_downstream_pipeline_service.rb

Overview

Enqueues the downstream pipeline worker.

Instance Method Summary collapse

Constructor Details

#initialize(bridge) ⇒ TriggerDownstreamPipelineService

Returns a new instance of TriggerDownstreamPipelineService.



6
7
8
9
10
11
# File 'app/services/ci/trigger_downstream_pipeline_service.rb', line 6

def initialize(bridge)
  @bridge = bridge
  @current_user = bridge.user
  @project = bridge.project
  @pipeline = bridge.pipeline
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/ci/trigger_downstream_pipeline_service.rb', line 13

def execute
  unless bridge.triggers_downstream_pipeline?
    return ServiceResponse.success(message: 'Does not trigger a downstream pipeline')
  end

  if rate_limit_throttled?
    bridge.drop!(:reached_downstream_pipeline_trigger_rate_limit)

    return ServiceResponse.error(message: 'Reached downstream pipeline trigger rate limit')
  end

  CreateDownstreamPipelineWorker.perform_async(bridge.id)

  ServiceResponse.success(message: 'Downstream pipeline enqueued')
end