Class: Ci::CreatePipelineService
- Inherits:
-
BaseService
- Object
- BaseService
- Ci::CreatePipelineService
- Defined in:
- app/services/ci/create_pipeline_service.rb
Constant Summary collapse
- CreateError =
Class.new(StandardError)
- SEQUENCE =
[Gitlab::Ci::Pipeline::Chain::Build, Gitlab::Ci::Pipeline::Chain::Build::Associations, Gitlab::Ci::Pipeline::Chain::Validate::Abilities, Gitlab::Ci::Pipeline::Chain::Validate::Repository, Gitlab::Ci::Pipeline::Chain::Config::Content, Gitlab::Ci::Pipeline::Chain::Config::Process, Gitlab::Ci::Pipeline::Chain::RemoveUnwantedChatJobs, Gitlab::Ci::Pipeline::Chain::Skip, Gitlab::Ci::Pipeline::Chain::SeedBlock, Gitlab::Ci::Pipeline::Chain::EvaluateWorkflowRules, Gitlab::Ci::Pipeline::Chain::Seed, Gitlab::Ci::Pipeline::Chain::Limit::Size, Gitlab::Ci::Pipeline::Chain::Limit::Deployments, Gitlab::Ci::Pipeline::Chain::Validate::External, Gitlab::Ci::Pipeline::Chain::Populate, Gitlab::Ci::Pipeline::Chain::StopDryRun, Gitlab::Ci::Pipeline::Chain::Create, Gitlab::Ci::Pipeline::Chain::Limit::Activity, Gitlab::Ci::Pipeline::Chain::Limit::JobActivity, Gitlab::Ci::Pipeline::Chain::CancelPendingPipelines, Gitlab::Ci::Pipeline::Chain::Metrics, Gitlab::Ci::Pipeline::Chain::Pipeline::Process].freeze
Instance Attribute Summary collapse
-
#pipeline ⇒ Object
readonly
Returns the value of attribute pipeline.
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
-
#execute(source, ignore_skip_ci: false, save_on_errors: true, trigger_request: nil, schedule: nil, merge_request: nil, external_pull_request: nil, bridge: nil, **options, &block) ⇒ Ci::Pipeline
Create a new pipeline in the specified project.
-
#execute!(*args, &block) ⇒ Object
rubocop: enable Metrics/ParameterLists.
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 Attribute Details
#pipeline ⇒ Object (readonly)
Returns the value of attribute pipeline
5 6 7 |
# File 'app/services/ci/create_pipeline_service.rb', line 5 def pipeline @pipeline end |
Instance Method Details
#execute(source, ignore_skip_ci: false, save_on_errors: true, trigger_request: nil, schedule: nil, merge_request: nil, external_pull_request: nil, bridge: nil, **options, &block) ⇒ Ci::Pipeline
Create a new pipeline in the specified project.
rubocop: disable Metrics/ParameterLists
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/services/ci/create_pipeline_service.rb', line 51 def execute(source, ignore_skip_ci: false, save_on_errors: true, trigger_request: nil, schedule: nil, merge_request: nil, external_pull_request: nil, bridge: nil, **, &block) @pipeline = Ci::Pipeline.new command = Gitlab::Ci::Pipeline::Chain::Command.new( source: source, origin_ref: params[:ref], checkout_sha: params[:checkout_sha], after_sha: params[:after], before_sha: params[:before], # The base SHA of the source branch (i.e merge_request.diff_base_sha). source_sha: params[:source_sha], # The HEAD SHA of the source branch (i.e merge_request.diff_head_sha). target_sha: params[:target_sha], # The HEAD SHA of the target branch. trigger_request: trigger_request, schedule: schedule, merge_request: merge_request, external_pull_request: external_pull_request, ignore_skip_ci: ignore_skip_ci, save_incompleted: save_on_errors, seeds_block: block, variables_attributes: params[:variables_attributes], project: project, current_user: current_user, push_options: params[:push_options] || {}, chat_data: params[:chat_data], bridge: bridge, **(**)) # Ensure we never persist the pipeline when dry_run: true @pipeline.readonly! if command.dry_run? Gitlab::Ci::Pipeline::Chain::Sequence .new(pipeline, command, SEQUENCE) .build! schedule_head_pipeline_update if pipeline.persisted? # If pipeline is not persisted, try to recover IID pipeline.reset_project_iid unless pipeline.persisted? pipeline end |
#execute!(*args, &block) ⇒ Object
rubocop: enable Metrics/ParameterLists
93 94 95 96 97 98 99 |
# File 'app/services/ci/create_pipeline_service.rb', line 93 def execute!(*args, &block) execute(*args, &block).tap do |pipeline| unless pipeline.persisted? raise CreateError, pipeline. end end end |