Class: Ci::CreateDownstreamPipelineService
- Inherits:
-
BaseService
- Object
- BaseService
- Ci::CreateDownstreamPipelineService
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/services/ci/create_downstream_pipeline_service.rb
Overview
Takes in input a Ci::Bridge job and creates a downstream pipeline (either multi-project or child pipeline) according to the Ci::Bridge specifications.
Constant Summary collapse
- DuplicateDownstreamPipelineError =
Class.new(StandardError)
- MAX_DESCENDANTS_DEPTH =
2
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
Methods included from Gitlab::Utils::StrongMemoize
#clear_memoization, #strong_memoize, #strong_memoized?
Methods inherited from BaseService
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
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#execute(bridge) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/services/ci/create_downstream_pipeline_service.rb', line 14 def execute(bridge) @bridge = bridge if bridge.has_downstream_pipeline? Gitlab::ErrorTracking.track_exception( DuplicateDownstreamPipelineError.new, bridge_id: @bridge.id, project_id: @bridge.project_id ) return end pipeline_params = @bridge.downstream_pipeline_params target_ref = pipeline_params.dig(:target_revision, :ref) return unless ensure_preconditions!(target_ref) service = ::Ci::CreatePipelineService.new( pipeline_params.fetch(:project), current_user, pipeline_params.fetch(:target_revision)) downstream_pipeline = service.execute( pipeline_params.fetch(:source), pipeline_params[:execute_params]) do |pipeline| pipeline.variables.build(@bridge.downstream_variables) end downstream_pipeline.tap do |pipeline| update_bridge_status!(@bridge, pipeline) end end |